簡體   English   中英

我有頻域方程。 如何使用IFFT在時空域中返回?

[英]I have the equation in frequency domain; How to go back in time and space domain with 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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM