Question
clear all clr H=tf([1 -1 -2],[1 1.5 -1],1); poles_H=roots([1 1.5 -1]) syms z Y(z)=(z/(z-1))*((z^2-z-2)/(z^2+1.5*z-1)) y_n=iztrans(y) n=0:1:6 y_n_7=double(subs(y_n)) stem(n,y_n_7,'linewidth',2) grid on ylim([-20 40]) xlim([-1 7]) xlabel
clear all
clr
H=tf([1 -1 -2],[1 1.5 -1],1);
poles_H=roots([1 1.5 -1])
syms z
Y(z)=(z/(z-1))*((z^2-z-2)/(z^2+1.5*z-1))
y_n=iztrans(y)
n=0:1:6
y_n_7=double(subs(y_n))
stem(n,y_n_7,'linewidth',2)
grid on
ylim([-20 40])
xlim([-1 7])
xlabel ('Samples (n)')
ylabel ('Value')
title ('First 7 samples of step response')
I was trying to use this code in octave but some commands were not possible because they belong to Matlab. An expert helped me out and solved 95% of my problems, but I am still having problem with H. H=tf([1 -1 -2],[1 1.5 -1],1);
New code that work 95%
clear all
H=tf([1 -1 -2],[1 1.5 -1],1);
poles_H=roots(poly(H)) % Find the poles of H
Y=@(z) (z./(z-1)).*((z.^2-z-2)./(z.^2+1.5*z-1));
y_n=ifft(Y(exp(2*pi*1i*(0:6)/7))); % Compute the first 7 samples of the step response
n=0:1:6;
y_n_7=real(y_n);
stem(n,y_n_7,'linewidth',2)
grid on
ylim([-20 40])
xlim([-1 7])
xlabel('Samples(n)')
ylabel('Value')
title('First 7 samples of step response')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started