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!
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!