from time domain to frequency domain and back to time domain
이전 댓글 표시
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)
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!