索性_ 2019-04-18 23:07
浏览 113

把下列代码的很坐标改成时间t

如何把下列的代码横坐标改成时间t?

%利用db8小波对信号进行5层分解
%生产正弦信号
clc;close all;clear all;
N=1000;
t=0.1:N;
sig1=cos(2*pi*50*t)+0.2*cos(3*2*pi*50*t)+0.1*cos(5*2*pi*50*t)+(1/15)*cos(7*2*pi*50*t);%信号
sig2(1:500)=((1:500)-1)/500;
sig2(501:N)=(1000-(501:1000))/500;
figure(1);
subplot(211);
plot(t,sig1,'linewidth',2);
xlabel('样本序号 N');
ylabel('幅值A');
subplot(212);
plot(t,sig2,'linewidth',2);
xlabel('样本序号 N');
ylabel('幅值A');
%叠加信号
x=sig1+sig2+randn(1,N);
figure(2);
plot(t,x,'linewidth',2);
xlabel('样本序号 N');
ylabel('幅值A');%一维小波分解
[c,l]=wavedec(x,7,'db5');%重构第1-5层逼近系数
a5=wrcoef('a',c,l,'db5',5);
a4=wrcoef('a',c,l,'db5',4);
a3=wrcoef('a',c,l,'db5',3);
a2=wrcoef('a',c,l,'db5',2);
a1=wrcoef('a',c,l,'db5',1);%显示逼近系数
figure(3)
subplot(713)
plot(a5,'linewidth',2);
ylabel('a5');
subplot(714)
plot(a4,'linewidth',2);
ylabel('a4');
subplot(715)
plot(a3,'linewidth',2);
ylabel('a3');
subplot(716)
plot(a2,'linewidth',2);
ylabel('a2');
subplot(717)
plot(a1,'linewidth',2);
ylabel('a1');
xlabel('样本序号 N');%重构第1-5层细节系数
d5=wrcoef('d',c,l,'db5',5);
d4=wrcoef('d',c,l,'db5',4);
d3=wrcoef('d',c,l,'db5',3);
d2=wrcoef('d',c,l,'db5',2);
d1=wrcoef('d',c,l,'db5',1);
%显示细节系数
figure(4)
subplot(713)
plot(d5,'linewidth',2);
ylabel('d5');
subplot(714)
plot(d4,'linewidth',2);
ylabel('d4');
subplot(715)
plot(d3,'linewidth',2);
ylabel('d3');
subplot(716)
plot(d2,'linewidth',2);
ylabel('d2');
subplot(717)
plot(d1,'linewidth',2);
ylabel('d1');
xlabel('样本序号 N');

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料