xinhao1.m

来自「应用matlab应用平台信号采集程序设计与整理。」· M 代码 · 共 43 行

M
43
字号
%采样频率为1000Hz;%数据长度为1024;%信号生成t=0:0.001:1.023;for i=1:1024    x(i)=8*sin(80*pi*t(i))+6*sin(200*pi*t(i))+sin(280*pi*t(i));    if t(i)<=0.2        s(i)=0;    else        s(i)=20*sin(2*pi*200*t(i)+pi/3).*exp(-20*(t(i)-0.2));    endendx=x+s;%graph signal xfigure(1);plot(t,x);xlabel('time/s');ylabel('amplitude/mv');title('signal x');axis([0 1.023 -40 40]);%3level 2^4=16, choose db wavelet package decompositionwptree=wpdec(x,3,'db3');                             %wpdec functionplot(wptree);										   %wavelet package tree figure(3);%section 1 to section 8 分解结果for i=0:7    subplot(4,2,i+1); section=wprcoef(wptree,[3 i]);    plot(section);axis([0 1024 min(section) max(section)]);    grid on;title(['section',num2str(i)]);   end    %Energy 每层的能量图谱for i=1:3    wptree=wpdec(x,i,'db3');       e=wenergy(wptree);    figure(4);    subplot(3,1,i);    bar(e);    axis([0 length(e) 0 150]);    title(['第 ',num2str(i), ' 层']);    for j=1:length(e)        text(j-0.2,e(j)+20,num2str(e(j),'%2.2f'));    endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?