Contents
Initialize system and generate input signals
a = -0.8;
N = 20;
delta = [1 zeros(1,N)];
u = ones(1,N+1);
Simulation
h = length(delta); h(1) = delta(1);
for n = 2:N+1
h(n) = delta(n) - a*h(n-1);
end
s = length(u); s(1) = u(1);
for n = 2:N+1
s(n) = u(n) - a*s(n-1);
end
Graphics
figure('Name',['1st order system with a = ',num2str(a)],'NumberTitle','off');
subplot(1,2,1); stem(0:length(h)-1,h,'filled'); grid
axis([0,length(h)-1,0,5]); xlabel('n \rightarrow'); ylabel('h[n] \rightarrow')
subplot(1,2,2); stem(0:length(s)-1,s,'filled'); grid
axis([0,length(s)-1,0,5])
xlabel('n \rightarrow'); ylabel('s[n] \rightarrow')