Derive & plot a step response of ss equation

1 次查看(过去 30 天)
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!

回答(1 个)

Santhana Raj
Santhana Raj 2017-5-4
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by