我想通过反向快速傅立叶变换找到时间置换曲线

发布于 2025-01-17 21:56:09 字数 836 浏览 2 评论 0原文

import numpy as np
import matplotlib.pyplot as plt

N=1000; T=10; dt=T/N
t=np.arange(0,N*dt,dt)

#system properties
wn = 4 * np.pi
w=0.2*wn
Tn = 2*np.pi/wn
fn = 1/Tn

m = 1
Z = 0.05
k = wn*wn * m
c = 2*m*wn*Z
######################################################
P = np.sin(wn * t)

#Frequency response
L = len(P)
a = np.arange(L)
freq = a * (1/dt) / L
freq = freq[range(int(L/2))]

Pf = np.fft.fft(P)/L
Pf = Pf[range(int(L/2))]
FFT = 2*abs(Pf)
#########################################################
# transfer function
H=(1/k)*(1/(1+(w/wn)**2)+1j*(2*Z*(w/wn)))

Uf=2*Pf*H

# for i in range(0,int(N/2)):
#     Uf[N-i-1] = np.conjugate(Uf[i+1])

ut= np.real(np.fft.ifft(Uf)*(1/dt))

plt.plot(t, ut)
plt.show()

我不知道这个 ValueError ValueError:x 和 y 必须具有相同的第一维度,但具有形状 (1000,) 和 (500,) 我想通过快速傅里叶逆变换找到时间-位移曲线

import numpy as np
import matplotlib.pyplot as plt

N=1000; T=10; dt=T/N
t=np.arange(0,N*dt,dt)

#system properties
wn = 4 * np.pi
w=0.2*wn
Tn = 2*np.pi/wn
fn = 1/Tn

m = 1
Z = 0.05
k = wn*wn * m
c = 2*m*wn*Z
######################################################
P = np.sin(wn * t)

#Frequency response
L = len(P)
a = np.arange(L)
freq = a * (1/dt) / L
freq = freq[range(int(L/2))]

Pf = np.fft.fft(P)/L
Pf = Pf[range(int(L/2))]
FFT = 2*abs(Pf)
#########################################################
# transfer function
H=(1/k)*(1/(1+(w/wn)**2)+1j*(2*Z*(w/wn)))

Uf=2*Pf*H

# for i in range(0,int(N/2)):
#     Uf[N-i-1] = np.conjugate(Uf[i+1])

ut= np.real(np.fft.ifft(Uf)*(1/dt))

plt.plot(t, ut)
plt.show()

i don't know this ValueError
ValueError: x and y must have same first dimension, but have shapes (1000,) and (500,)
I want to find the time-displacement curve through inverse fast Fourier transform

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等待我真够勒 2025-01-24 21:56:09

plt.plot()功能只是抱怨tut没有相同的长度。

此行pf = pf [range(int(l/2))]pf从长度nn /2。这会影响uf,因此ut,这就是为什么您会收到错误消息的原因。我不确定您在此命令中要做什么...您是否试图过滤某些频率?无论哪种方式,再看一下此命令都可能给您想要的东西。

The plt.plot() function is just complaining that t and ut do not have the same length.

This line Pf = Pf[range(int(L/2))] takes Pf from an array of length N to N/2. This affects Uf and consequently ut, and that is why you get the error message. Im not sure what you are trying to do in this command... are you trying to filter out certain frequencies? Either way, taking another look at this command might give you what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文