%序列 x = [3,11,7,0,-1,4,2]; h=[2,3,0,-5,2,1]
%用两种方法求两者的线性卷积y
clc; %清屏
clear all;
x = [3,11,7,0,-1,4,2]; %x的序列
nx = [0:length(x)-1]; %x的序列对应的长度
h=[2,3,0,-5,2,1]; %h序列
nh = [0:length(h)-1]; %h序列对应的长度
y = conv(x,h); %利用conv函数进行x,h的卷积
ny = [0:1:length(y)-1]; %函数卷积y的长度
subplot(1,3,1); %分为1行3列
stem(nx,x); %x序列的图像
xlabel(\'n\');
ylabel(\'幅度\');
title(\'X\');
subplot(1,3,2); %h序列的图像
stem(nh,h);
xlabel(\'h\');
ylabel(\'幅度\');
title(\'h\');
subplot(1,3,3); %线性卷积的序列
stem(ny,y);
xlabel(\'y\');
ylabel(\'幅度\');
title(\'线性卷积\');