我有一个频域方程的解(解析解);如何使用IFFT返回时空域?
我尝试在公式中输入频率样本(w,xi),然后对结果进行IFFT。但是,我不确定是否正确执行了操作。我已经读过关于插值,Dirichel等的信息,但是我不确定如何实现它们。有人可以指导我吗?
谢谢。
接下来,我提供两个MATLAB文件: 1.主要代码 2.所需的功能
这是主要代码:
clc;clear all;close all;
tic;
%The function in frequency domain
%[wdf]=DynResp(0.01,w,xi); where 0.1 is constant,
%xi is the x (space) in frequency domain and
%w is the t (time) in frequency domain
Nt=1000; %number of samples for the frequency w
dw=1/196;
w_max=dw*Nt;
w=[0:dw:w_max,-w_max+dw:dw:-dw];
t_max=1/(dw*2*Nt);
dt=t_max/(2*Nt);
t=[dt:dt:t_max];
Nx=1000; %number of samples for the frequency w
dxi=1/196;
xi_max=dxi*Nx;
xi=[0:dxi:xi_max,-xi_max+dxi:dxi:-dxi];
xi(xi==0)=100000000000; % for xi =0 the function goes to Infinity thus instead of 0 i give a bug number
x_max=1/(dxi*2*Nx);
dx=x_max/(2*Nx);
x=[dx:dx:x_max];
% Here i input the samples frequencies to the function (equation)
for i=2:2*Nx
for j=2:2*Nt
xiw_DynaFdom(i,j)=DynResp(0,w(j),xi(i));
end
end
% here is the inverse fourier transform of both xi and w to the x and t
xt_DynaT=(ifftshift(ifft2((wDynaFdom))))*Nx*Nt*dw*dxi/(pi^2);
% A plot in 3d
surface(x,t,real(wDynaT))
xlabel('x (m)') % x-axis label
ylabel('time(s)') % y-axis labe
zlabel('disp(m)') % y-axis labe
[max_idx] = max(max(wDynaT)); % Just the place of the maximum response in order to check the results
% A plot in 2d
for i=1:length(w)
plot(x,real(wDynaT(:,max_idx)))
end
功能如下:
function [wdf] = DynResp(z,w,xi)
format long e;
P=15;m=10/9.80665;c=500/m;EE=40*10^6;II=1*
(0.20^3)/12;EI=EE*II;k=120*10^3;l=50;
a0=0.1;v0=10;
wdf=(P*sqrt(2*pi)*exp(1i*((xi*v0+w)^2)/(2*a0*xi)))/(sqrt(1i*a0*xi)*(EI*xi^4+k+1i*w*c-m*w^2));
end
答案 0 :(得分:-2)
在使用Scipy的python中,可以通过这种方式完成。我没有Matlab可以尝试。
from scipy import fftpack
import numpy as np
import matplotlib.pyplot as plt
tr = np.cos(np.arange(100))
plt.plot(tr)
plt.title('original array')
plt.show()
fy = fftpack.fft(tr) #tr is some equally sampled array
amp = np.abs(fy)
phase = np.angle(fy)
# here you might apply some analysis filtering to amp or phase.
# amp : using multiplication, phase: using addition and substraction
tr_inverse = np.real(fftpack.ifft(amp * (np.cos(phase) + 1j*np.sin(phase))))
plt.plot(tr_inverse)
plt.title('recovered array')
plt.show()
1j
是复数sqrt(-1)
我认为从python转换为Matlab很容易