micky_hkw 发表于 2006-5-18 21:13

求助各位!帮我看一下程序!

clear;close all;
fs=1024;%采样频率
N=1024;%采样点数
dt=1/fs;%采样间隔
t=(0:N-1)*dt;
f=50;%基波频率
w=2*pi*f;
s1=sin(w*t);
subplot(4,1,1);plot(s1);
axis();
s2=1/3*sin(3*w*t);
subplot(4,1,2);plot(s2);
axis();
s3=1/5*sin(5*w*t);
subplot(4,1,3);plot(s3);
axis();
s4=1/7*sin(7*w*t);
subplot(4,1,4);plot(s4);
axis();
s=s1+s2+s3+s4;
figure(2);
plot(s);xlabel('时间 t/s');ylabel('幅值 A');
axis();
=wavedec(s,5,'sym6');
a5=wrcoef('a',c,l,'sym6',5);
a4=wrcoef('a',c,l,'sym6',4);
a3=wrcoef('a',c,l,'sym6',3);
a2=wrcoef('a',c,l,'sym6',2);
a1=wrcoef('a',c,l,'sym6',1);
figure(3);
subplot(5,1,1);plot(a5,'LineWidth',1);ylabel('a5');
axis();
subplot(5,1,2);plot(a4,'LineWidth',1);ylabel('a4');
axis();
subplot(5,1,3);plot(a3,'LineWidth',1);ylabel('a3');
axis();
subplot(5,1,4);plot(a2,'LineWidth',1);ylabel('a2');
axis();
subplot(5,1,5);plot(a1,'LineWidth',1);ylabel('a1');
axis();
xlabel('时间 t/s');
d5=wrcoef('d',c,l,'sym6',5);
d4=wrcoef('d',c,l,'sym6',4);
d3=wrcoef('d',c,l,'sym6',3);
d2=wrcoef('d',c,l,'sym6',2);
d1=wrcoef('d',c,l,'sym6',1);
figure(4);
subplot(5,1,1);plot(d5,'LineWidth',1);ylabel('d5');
axis();
subplot(5,1,2);plot(d4,'LineWidth',1);ylabel('d4');
axis();
subplot(5,1,3);plot(d3,'LineWidth',1);ylabel('d3');
axis();
subplot(5,1,4);plot(d2,'LineWidth',1);ylabel('d2');
axis();
subplot(5,1,5);plot(d1,'LineWidth',1);ylabel('d1');
axis();
xlabel('时间 t/s');
以上是小波分析,然后我想要把a1~5和d1~5(每一层也就是一个波形)用FFT画出频谱图,该怎么做?

happy 发表于 2006-5-18 21:21

在命令窗口输入doc fft自己看帮助吧,里边有例子

然后再看一下帖子
http://forum.vibunion.com/thread-10344-1-1.html

估计就没什么问题了

micky_hkw 发表于 2006-5-19 15:45

要是纵坐标要用幅值表示该如何做?

yangzj 发表于 2006-5-19 15:50

对fft的结果取abs
页: [1]
查看完整版本: 求助各位!帮我看一下程序!