Derive & plot a step response of ss equation

2 views (last 30 days)
ERica Ho
ERica Ho on 4 May 2017
Answered: Santhana Raj on 4 May 2017
trying to plot a step response using the y equation my lecturer provided, and here's my Script:
A=[0 0 -2;1 0 -5;0 1 -4]; %Inputs b=[1;0;0]; c=[9 -26 66]; d=0; [b,a]=ss2tf(A,b,c,d); %convert to transfer function [r,p,k]=residue(b,a); %extracting partial fractions t=0 %Initial Condition
for i=1:1:10 t=t+0.1 y=1+r(1)*exp(-t)+r(2)*t*exp(-t)+r(3)*exp(-2*t)
end;
Tried plotting it but the plot is blank? My Matlab skills aren't to great either. Thanks!

Answers (1)

Santhana Raj
Santhana Raj on 4 May 2017
First of all, try to use the {}code button, when you write the code. It will be easier to understand and has more probability that you will get an answer.
The mistake is neither your t nor your y is a vector. You want it to be so, if you want o plot it. On every iteration, the value of y gets replaced!! so you have only one value of y at the end instead of 10.
y(i)=1+r(1)*exp(-t)+r(2)*t*exp(-t)+r(3)*exp(-2*t);
Try the above line within your for loop. I think it should work.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!