首页 > 解决方案 > 我有频域方程;IFFT如何回到时空域?

问题描述

我有频域方程的解(解析解);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

标签: matlabfftinterpolationifft

解决方案


在使用 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 很容易


推荐阅读