Why am I getting complex values in a function after IFFT function?
Show older comments
I have taken a simple function (the code below) for illustration to understand my real MATLAB code. I was taught that when we do an FFT of any function (denoted by y_ft), we get the function in a frequency domain that has complex values (e.g.,:a+ib). After taking the IFFT (variable: y_ifft), I should get the function value with only real numbers (just a's). But in the below code, my y_ifft has still complex values. Why is that? Since the Fourier analysis concepts are new learning to me, I am missing some concept here. Answers are appreciable.
f0=4; % frquency of a sine wave
Fs=100; % sampling rate
dt=1/Fs; %sampling interval
t=0:dt:1-dt; % time axis
n=length(t); %number of samples
y=2*sin(2*pi*f0*t); %sine function
figure()
plot(t,y);
y_ft=fft(y);
y_ifft=ifft(y);
figure()
stem(abs(y_ft),'*');
Accepted Answer
More Answers (0)
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!