from time domain to frequency domain and back to time domain
Show older comments
Hi to everybody,
I am trying to jump from a frequency response to an impulse response and I need to start from sth basic so I understand how it works.
Can someone please help me understand why the last plot doesn't look like the first (the one that is commented out in the code) one? I would expect them to be the same.
% N=100000; % the number of data points
% fs=44100; % sample rate, number of samples per second
% dt=1/fs;% time increment (in seconds per sample)
% t=dt*(0:N-1); % time domain (in seconds)
% fc=100; % carrier frequency
% x=sin(2*pi*fc*t); % sine
% figure()
% plot(t,x)
%spectrum
X=fftshift(fft(x)); % DFT and shift center to zero
df=fs/N; % the frequency increment
f=-fs/2:df:fs/2-df; % create the frequency axis
figure()
plot(f,abs(X))
% reverse procedure
y=ifft(X); % inverse fft
N2=length(X); % determine the length of the signal
dt2=1/fs; % determine the time increment
tim=0:dt2:(N2-1)*dt2; %create the time axis
figure()
plot(tim,y)
Accepted Answer
More Answers (0)
Categories
Find more on Scopes and Data Logging 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!