n=[0:4];
x1=[1,1,1,1,1,0];
x2=[5,3,7,1,2,6];
[y]=circonvt(x1,x2,5);
stem(n,y);xlabel('n');ylabel('y');
function y=cirshftt(N,x,m)
if length(x)>N
error('N must be >= the length of x');
end
x=[x,zeros(1,N-length(x))];
n=[0:1:N-1];
n=mod(n-m,N);
y=x(n+1);
end
function y=circonvt(x1,x2,N)
if length(x1)>N
error('N must be >= the length of x1')
end
if length(x2)>N
error('N must be >= the length of x2')
end
x1=[x1,zeros(1,N-length(x1))];
x2=[x2,zeros(1,N-length(x2))];
m=0:1:N-1;
x2=x2(mod(-m,N)+1);
H=zeros(N,N);
for n=1:N
H(n,:)=cirshftt(x2,n-1,N);
end
y=xl*H';
end
matlab程序编辑出现错误
最新推荐文章于 2024-01-01 12:21:31 发布