How to display the state variable in a graphic?
2 views (last 30 days)
Show older comments
In simulink, when you have a graphic with many variables curves, how do you can distinguish one variable from another?
0 Comments
Answers (1)
Avinash Mangena
on 4 Nov 2020
You can use “plot(___,Name,Value)” which is used to distinguish one variable from another.
This specifies line properties using one or more Name,Value pair arguments. For a list of properties, see Line Properties[AV1] [AM2] . Use this option with any of the input argument combinations in the previous syntaxes. Name-value pair settings apply to all the lines plotted.
For better understanding you can refer to following example:
x = linspace(0,10);
y1 = sin(x);
y2 = sin(0.9*x);
y3 = sin(0.8*x);
y4 = sin(0.7*x);
y5 = sin(0.6*x);
y6 = sin(0.5*x);
plot(x,y1,'DisplayName','sin(x)')
hold on
plot(x,y2,'DisplayName','sin(0.9x)')
plot(x,y3,'DisplayName','sin(0.8x)')
plot(x,y4,'DisplayName','sin(0.7x)')
plot(x,y5,'DisplayName','sin(0.6x)')
plot(x,y6,'DisplayName','sin(0.5x)')
hold off
lgd = legend;
lgd.NumColumns = 2;
hope it helps !
1 Comment
See Also
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!