I have the solution of an equation (analytic solution) in frequency domain; How to go back in time and space domain with IFFT?
I try to input frequency samples (w, xi) in the equation and then to IFFT the results. However I am not sure if I did it correctly. I have read about interpolation, Dirichel etc. but i am not sure how to implement them. Can anybody guide me?
Thank you in advance.
Next I provide the two MATLAB files: 1.The main code 2.The function needed
Here is the main code:
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
Here is the function:
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