该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
function [y,ny]=my_conv(h,nh,x,nx)
nxs=-3;
nxf=0;
nhs=-1;
nhf=1;
x=[3,4,5,6];
h=[1,2,3];
nx=nxs:nxf;
nh=nhs:nhf;
nys=nxs+nhs;
nyf=nxf+nhf;
ny=nys:nyf;
c=fliplr(h);
K=length(h);
M=length(x);
x1=[zeros(1,K) x zeros(1,K-1)];
h1=[zeros(1,K+abs(nxs)-abs(nhs)) h zeros(1,abs(nxf)+K-1-abs(nhf))];
c1=[c zeros(1,M+K-1)];
d=-(K+abs(nxs)):K+abs(nxf)-1;
s= -(abs(nxs)+abs(nhs)+1):K+abs(nxf)-1;
L=length(d);
A=length(s);
y1=[zeros(1,A)];
subplot(2,2,3)
stem(d,x1);
hold on
stem(d,h1);
pause(1);
y=zeros(1,A);
c1
for i=1:L+1;
% clf
c2=[zeros(1:i-1) c1(1:L-i+1)];
% Hf = [Hf zeros(1,n+k-1)];
% Hc = [zeros(1,i-1) Hf(1:L-i+1)];
c2
y(i)=sum(x1.*c2) ;
subplot(2,2,1)
stem(d,x1);
title('X');
subplot(2,2,2)
stem(d,h1);
title('H');
subplot(2,2,3)
stem(d,x1);
hold on
stem(d,c2);
title('x*h(n-m)');
subplot(2,2,4)
stem(s,y);
pause(1);
title('y');
end
错误使用 horzcat
串联的矩阵的维度不一致。出错 my_conv2 (line 33)
c2=[zeros(1:i-1) c1(1:L-i+1)];