你好,答案仅供参考
function main
n = -10:1:10;
x1 = zeros(size(n));
x2 = x1;
for j = 1:1:numel(n)
nj = n(j);
x1(j) = R4(nj);
x2(j) = 2^(nj)*(u(nj)-u(nj-5));
end
g = conv(x1,x2,'same');
plot(n,g)
end
function x = R4(n)
Q = 0:1:3;
if(ismember(n,Q))
x = 1;
else
x = 0;
end
end
function x = u(n)
if(n>=0)
x = 1;
else
x = 0;
end
end