matlab绘图无错误提示 却显示空白图N=100;n=0:N-1;b=1;a=[1 -1 0.9];x1=Heaviside(n);y1=filter(b,a,x1); x2=n.*(Heaviside(n)-Heaviside(n-30));y2=filter(b,a,x2);x3=exp(n*j*pi/4).*Heaviside(n);y3=filter(b,a,x3);subplot(2,2,1);stem(n,y1,'.');axis
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 03:16:51
matlab绘图无错误提示 却显示空白图N=100;n=0:N-1;b=1;a=[1 -1 0.9];x1=Heaviside(n);y1=filter(b,a,x1); x2=n.*(Heaviside(n)-Heaviside(n-30));y2=filter(b,a,x2);x3=exp(n*j*pi/4).*Heaviside(n);y3=filter(b,a,x3);subplot(2,2,1);stem(n,y1,'.');axis
matlab绘图无错误提示 却显示空白图
N=100;n=0:N-1;
b=1;
a=[1 -1 0.9];
x1=Heaviside(n);
y1=filter(b,a,x1);
x2=n.*(Heaviside(n)-Heaviside(n-30));
y2=filter(b,a,x2);
x3=exp(n*j*pi/4).*Heaviside(n);
y3=filter(b,a,x3);
subplot(2,2,1);stem(n,y1,'.');axis([0,N,-1,2]);ylabel('y1(n)');grid on
subplot(2,2,2);stem(n,y1,'.');axis([0,N,-1,2]);ylabel('y2(n)');grid on
subplot(2,2,3);stem(n,y1,'.');axis([0,N,-1,2]);ylabel('y3(n)');grid on
绘完图弹出绘图窗口 却显示空白,请问是我哪里出错了吗?
matlab绘图无错误提示 却显示空白图N=100;n=0:N-1;b=1;a=[1 -1 0.9];x1=Heaviside(n);y1=filter(b,a,x1); x2=n.*(Heaviside(n)-Heaviside(n-30));y2=filter(b,a,x2);x3=exp(n*j*pi/4).*Heaviside(n);y3=filter(b,a,x3);subplot(2,2,1);stem(n,y1,'.');axis
你不能用heaviside来生成阶跃函数的,他生成的阶跃函数在x=0时为NaN,一滤波就全都是NaN了.改为如下程序:
N=100;n=0:N-1;
b=1;
a=[1 -1 0.9];
x1=(n>=0);
y1=filter(b,a,x1);
x2=n.*((n>=0)-(n>=30));
y2=filter(b,a,x2);
x3=exp(n*j*pi/4).*(n>=0);
y3=filter(b,a,x3);
subplot(2,2,1);stem(n,y1,'.');ylabel('y1(n)');grid on
subplot(2,2,2);stem(n,y2,'.');ylabel('y2(n)');grid on
subplot(2,2,3);stem(n,y3,'.');ylabel('y3(n)');grid on