matlab零基础,语句不通请见谅
n=0:10; %长度
n1=0;n2=10;n01=2;
n=n1:n2;
x1=[(n-n01)==0];
x2=[n==0];
x=x2-x1;
subplot(3,1,1);stem(n,x); xlabel('n'); ylabel('x(n)');
axis([n1,n2,1.1*min(x),1.1*max(x)]);
h=zeros(1,length(n)); %生成h(n)矩阵
h([find((n>=0)&(n<=3))])=1; %输入序列h(n)
figure(1)
title('输入序列');
subplot(3,1,2); stem(n,h); xlabel('n'); ylabel('h(n)');
axis([0,10,0,2]);
y=conv(x,h); %对x(n),h(n)进行卷积计算
subplot(3,1,3);
n=0:length(y)-1;
stem(n,y);
title('输出响应');
xlabel('n'); ylabel('y(n)');