t=a(:,1);%%%%t是時間;yt=a(:,2);%%%%yt是數(shù)據(jù);
dt=t(2)-t(1);%%%%dt是點距;lt=length(t);%%%%是數(shù)據(jù)的長度;f0=2*pi/lt;%%%%f0是基頻;fy=fft(yt);%%%%fy是fft變換得到的波譜;
for i=1:1:lt f(i)=f0*(i-1);%%%%f是頻率; P(i)=abs(fy(i))^2;%%%P是功率譜;
endplot(f,P); %%%%畫圖;
t=a(:,1);%%%%t是時間;yt=a(:,2);%%%%yt是數(shù)據(jù);
dt=t(2)-t(1);%%%%dt是點距;lt=length(t);%%%%是數(shù)據(jù)的長度;f0=2*pi/lt;%%%%f0是基頻;fy=fft(yt);%%%%fy是fft變換得到的波譜;
for i=1:1:lt f(i)=f0*(i-1);%%%%f是頻率; P(i)=abs(fy(i))^2;%%%P是功率譜;
endplot(f,P); %%%%畫圖;