PlotOptions and Legend for Step Response

41 views (last 30 days)
Shilp Dixit
Shilp Dixit on 27 Nov 2013
Edited: Azzi Abdelmalek on 27 Nov 2013
Hi, I am facing a small issue with formatting my step response plots.
I have a state space description with
2 states, 1 input, 3 outputs
A = 2X2 matrix
B = 2X1 matrix
C = 3X2 matrix
D = 3X1 matrix
I have five different values of inputs. 3, 20, 30, 40, 60 and want to plot a single step response to compare the responses. To find a way around this i created
A as a 2X2X5 matrix and
C as a 3X2X5 matrix and then use the following functions.
sys = ss(A,B,C,D)
tf_sys = tf(sys)
When i use step(tf_sys). I am getting the correct step responses but all are of the same color and there is no legend. How can I modify plot style and enable legend for such a plot.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 27 Nov 2013
Edited: Azzi Abdelmalek on 27 Nov 2013
You can create your own plot and legend
A=[-11 -10;1 0];
B=[1;0];
C=eye(2);
D=[0;0];
sys=ss(A,B,C,D)
[x,t]=step(sys)
plot(t,x)
legend({'c1','c2'})

Community Treasure Hunt

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

Start Hunting!