matlab怎么绘制出功率谱


0 -5.09102
0.00024414063 -2.11288
0.00048828126 -4.86507
0.00073242189 3.52306
0.00097656252 -8.16756
0.00122070315 -4.78239
0.00146484378 -6.17004
0.00170898441 -10.5754
0.00195312504 -2.8902
0.00219726567 -3.86188
0.0024414063 -2.53418
0.00268554693 -8.04689
0.00292968756 -3.36227
0.00317382819 -0.479067

这是我的数据,前面是时间。

a=[0 -5.09102
0.00024414063 -2.11288
0.00048828126 -4.86507
0.00073242189 3.52306
0.00097656252 -8.16756
0.00122070315 -4.78239
0.00146484378 -6.17004
0.00170898441 -10.5754
0.00195312504 -2.8902
0.00219726567 -3.86188
0.0024414063 -2.53418
0.00268554693 -8.04689
0.00292968756 -3.36227
0.00317382819 -0.479067];
t=a(:,1);
yt=a(:,2);
dt=t(2)-t(1);
lt=length(t);
f0=2*pi/lt;
fy=fft(yt);
for i=1:1:lt
f(i)=f0*(i-1);
P(i)=abs(fy(i))^2;
end
plot(f,P); 展开追问 追问 帮忙附下解释,看不懂,我的数据多有些地方要修改 回答 t=a(:,1);%%%%t是时间;
yt=a(:,2);%%%%yt是数据;
dt=t(2)-t(1);%%%%dt是点距;
lt=length(t);%%%%是数据的长度;
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是功率谱;
end
plot(f,P); %%%%画图;
数据太多可以保存成文本形式??数据怎么修改法?


Copyright © 2009-2011 All Rights Reserved.