Step response:
clc;close all;clear all;
h=(-0.9).^[0:49];
u=ones(1,50)
s=conv(u,h)
subplot(311)
stem([0:49],u)
xlabel('n');ylabel('u(n)');title('step input')
subplot(312)
stem([0:49],h)
xlabel('n');ylabel('h(n)');title('Impulse response h(n)')
subplot(313)
stem([0:49],s(1:50))
xlabel('n');ylabel('s(n)');title('Step response s(n)')
Difference equation:
clc;close all;clear all;
a=[1 -1.143 0.4128]
b=[0.0675 0.1349 0.675]
%Zero input response
yi=[1 2]
x=zeros(1,50)
zi=filtic(b,a,yi)
y=filter(b,a,x,zi)
subplot(311)
stem([0:49],y(1:50))
xlabel('n');ylabel('y(n)');title('Zero input response')
%Zero state response
n=0:1:99
x=cos(pi*n/6)
y=filter(b,a,x)
subplot(312)
stem([0:99],y(1:100))
xlabel('n');ylabel('y(n)');title('Zero state response')
%Step response
x=ones(1,100)
y=filter(b,a,x)
subplot(313)
stem([0:99],y(1:100))
xlabel('n');ylabel('s(n)');title('Step response')
State variable description:
clc;close all;clear all;
A=[-0.5572 -0/7814 ;0.7814 0];
B=[1 -1;0 2];
C=[1.9691 6.4493];
D=0;
sys=ss(A,B,C,D,0.1)
figure;
step(sys)
figure;
impulse(sys)
figure;
x0 = [1 ; 0];
initial(sys,x0)
figure;
%Response to sinusoidal input
f=0.25
[u,t] = gensig('sin',1/f,10,0.1);
lsim(sys,[u,u],t)
1. Given the impulse response, h[n duration 50 samples. (-0.9)"u[n, find the step response for a step input of h-(0...