필터 지우기
필터 지우기

Difference in plotting the Power spectrum using two methods

조회 수: 1 (최근 30일)
Gova ReDDy
Gova ReDDy 2014년 4월 9일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by