错误使用 plot 向量长度必须相同怎么改啊 20
p=0.01;nf=0:p:2;f=2*((nf>=0)-(nf>=2));nh=0:p:4;h=exp(-nh);[y,k]=sconv(f,n,nf,nh,p);su...
p=0.01;
nf=0:p:2;
f=2*((nf>=0)-(nf>=2));
nh=0:p:4;
h=exp(-nh);
[y,k]=sconv(f,n,nf,nh,p);
subplot(3,1,1),stairs(nf,f);grid on
title('f(t)');axis([0 6 0 2.1]);
subplot(3,1,2),plot(nh,h);grid on
title('h(t)');axis([0 6 0 2.1]);
subplot(3,1,3),plot(k,y);grid on
title('y(t)=f(t)*h(t)');axis([0 6 0 2.1]);
function [y,k]=sconv(f,h,nf,nh,p)
y=conv(f,h);
y=y*p;
left=nf(1)+nh(1);
right=length(nf)+length(nh)-2;
k=p*(left:right);
end 展开
nf=0:p:2;
f=2*((nf>=0)-(nf>=2));
nh=0:p:4;
h=exp(-nh);
[y,k]=sconv(f,n,nf,nh,p);
subplot(3,1,1),stairs(nf,f);grid on
title('f(t)');axis([0 6 0 2.1]);
subplot(3,1,2),plot(nh,h);grid on
title('h(t)');axis([0 6 0 2.1]);
subplot(3,1,3),plot(k,y);grid on
title('y(t)=f(t)*h(t)');axis([0 6 0 2.1]);
function [y,k]=sconv(f,h,nf,nh,p)
y=conv(f,h);
y=y*p;
left=nf(1)+nh(1);
right=length(nf)+length(nh)-2;
k=p*(left:right);
end 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询