Difference in plotting the Power spectrum using two methods
1 次查看(过去 30 天)
显示 更早的评论
Hello, Ihave the pulse signal-a1 attached which was sampled by suing freq of 64Hz and duration of signal is 10 seconds(as length=640).I used the following two methods
%---Method1---%
a1=load('a1.mat');
a1=a1.a1;
fs=64;
x_fft=fft(a1); %fft of the signal
N=length(a1);
omega=fs*[(0:N/2) (-N/2+1:-1)]/N; %frequency axis(bins)
figure(1);
plot(omega(1:N/2),2*abs(x_fft(1:N/2))); %plot of one-sided spectrum
%----method2---%
Fs=64 ; % insert here your frequency sampling in Hz
L=length(a1);
NFFT = 2^nextpow2(L);
Y = fft(a1,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
figure(2);
plot(f,2*abs(Y(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
the plots are
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/160562/image.jpeg)
But I don't understand the difference between the both.
can someone explain me the difference between the two.
thanks.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!