MATLAB Answers

Problem in performing IFFT

9 views (last 30 days)
Susmita Panda
Susmita Panda on 30 Mar 2021
Commented: Susmita Panda on 28 May 2021 at 11:58
I have performed IFFT for converting frequency to time domain and back to frequency domain. I am getting same results also. However in time domain plot, my response should start with zero and I am getting slighly higher value at time zero.
Here is my code:
clear all
close all
clc
a=0.5;eta=0.3;beta=0.025;wb=14.25;
% Define time and frequency axis variables
fs =400; % samples/s
N = 1024; % number of points
dt = 1 / fs; % s, time step
t = (0:N-1)*dt; % s, time axis
df = 1 / N / dt; % Hz, frequency step
f = (-N/2:N/2-1)*df; % Hz, frequency axis
% Define function
y=sin(pi.*a).*eta.*(1+exp(-1i.*pi.*f./eta))./((-f.^2+(2.*1i).*f.*beta+1).*(eta.^2-f.^2));
%plot original signal
figure, plot(f,y),title('Frequency response');ylabel('Response of beam');xlabel('Frequency'); % plot initial time domain signal
%conversion to time domain
y2 = ifft(ifftshift(y));
figure, plot(t,(y2)),title('Time response');ylabel('Response of beam');xlabel('Time');
axis([0 2.5 -0.05 0.05]); % time domain signal after IFFT
%back to original signal
%y3=fftshift(fft(y2));
%figure,plot(f,y3),title('Frequency response');ylabel('Response of beam');xlabel('Frequency');
Any Help is highly appreciated.
Thanks
  3 Comments

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 31 Mar 2021
Edited: David Goodmanson on 31 Mar 2021
Hi Susmita,
A couple of things going on here. First, it's good to use more points. Use a lot more points. There is no need to go with something as small as 1024 and there is also no need to go with a power of 2, the importance of which, in my opinion, is a myth. I used a nice even million points in the code below.
Second, in the expression for y there is a factor of (eta^2-f.^2) in the denominator. That puts poles at +-eta on the real frequency axis. The path of integration runs right over them, so by implication you are taking the principal value of the integral. The p.v. is the same as the average value of two functions (y3 and y4 below) where the poles are moved slightly off of the real axis in either the plus or minus i direction. The small parameter gamma accomplishes that.
clear all
close all
clc
a=0.5;eta=0.3;beta=0.025;wb=14.25;gamma = 1e-10; % introduce gamma
% Define time and frequency axis variables
fs =400; % samples/s
N = 1e6; % number of points
dt = 1 / fs; % s, time step
t = (0:N-1)*dt; % s, time axis
df = 1 / N / dt; % Hz, frequency step
f = (-N/2:N/2-1)*df; % Hz, frequency axis
% Define function
y3=sin(pi.*a).*eta.*(1+exp(-1i.*pi.*f./eta))./((-f.^2+(2.*1i).*f.*beta+1).*(eta.^2-i*f*gamma-f.^2));
y4=sin(pi.*a).*eta.*(1+exp(-1i.*pi.*f./eta))./((-f.^2+(2.*1i).*f.*beta+1).*(eta.^2+i*f*gamma-f.^2));
y = (y3+y4)/2;
%plot original signal
figure(1)
% plot initial time domain signal
plot(f,y),title('Frequency response');ylabel('Response of beam');xlabel('Frequency');
grid on
%conversion to time domain
y2 = ifft(ifftshift(y));
figure(2)
plot(t,(y2)),title('Time response');ylabel('Response of beam');xlabel('Time');
axis([0 2.5 -0.05 0.05]); % time domain signal after IFFT
grid on
  4 Comments
Susmita Panda
Susmita Panda on 28 May 2021 at 11:58
@David Goodmanson Sir please help me out in my next question asked in the forum about IFFT. I really need great help from you this time.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!