Control systems: Labelling multiple plots dynamically based on parameter ?
2 次查看(过去 30 天)
显示 更早的评论
Hello! This is my first time using this forum. Basically I need some way to label the plots with the value of the variable 'zeta' so that my output (below)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/845475/image.png)
resembles this diagram (below) in my text book (the numbers "1.5", "1.0", "0.8", etc):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/845480/image.jpeg)
The code I have used is:
s = tf('s');
Wn = 1;
for zeta = 0.1:0.1:0.9
T = Wn^2/(s^2 + 2*zeta*Wn*s + Wn^2);
step(T);
hold all
end
0 个评论
采纳的回答
Burhan Burak AKMAN
2021-12-27
You can use this. May be it will help you.
s = tf('s');
Wn = 1;
i=1;
ti=linspace(0,20,200);
for zeta = 0.1:0.1:0.9
T = Wn^2/(s^2 + 2*zeta*Wn*s + Wn^2);
[a,b]=step(T,ti);
hold all
plot(b,a)
text(b(-i*2+40),a(-i*2+40),"\zeta="+string(zeta),'FontSize',10)
i=i+1;
end
0 个评论
更多回答(1 个)
Paul
2021-12-27
Here's a way to do it with a legend.
s = tf('s');
Wn = 1;
for zeta = 0.1:0.1:0.9
T = Wn^2/(s^2 + 2*zeta*Wn*s + Wn^2);
[y,t]=step(T);
plot(t,y,'DisplayName',"zeta = "+string(zeta))
hold all
end
legend
If you really want to annotate the curves themselves, check out
doc text
doc annotation
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!