Derive & plot a step response of ss equation

1 回表示 (過去 30 日間)
ERica Ho
ERica Ho 2017 年 5 月 4 日
回答済み: Santhana Raj 2017 年 5 月 4 日
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 Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by