Difference in plotting the Power spectrum using two methods

1 view (last 30 days)
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
But I don't understand the difference between the both.
can someone explain me the difference between the two.
thanks.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!