MATLAB Answers

Problem in performing IFFT

조회 수: 6(최근 30일)
Susmita Panda
Susmita Panda 2021년 3월 30일
댓글: Susmita Panda 2021년 5월 28일
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
Susmita Panda
Susmita Panda 2021년 4월 1일
Thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

David Goodmanson
David Goodmanson 2021년 3월 31일
편집: David Goodmanson 2021년 3월 31일
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
Susmita Panda
Susmita Panda 2021년 5월 28일
@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.

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by