Borrar filtros
Borrar filtros

Derive & plot a step response of ss equation

2 visualizaciones (últimos 30 días)
ERica Ho
ERica Ho el 4 de Mayo de 2017
Respondida: Santhana Raj el 4 de Mayo de 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!

Respuestas (1)

Santhana Raj
Santhana Raj el 4 de Mayo de 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.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by