How can I place labels on the end of my line plots?
20 ビュー (過去 30 日間)
古いコメントを表示
%%Question 1
clear clc
for r = 1:1:2
for a =[0.1 0.2 0.5 0.75 1.0]
if a==0
tend=0
else
tend=4/a
end
t=0:1:tend
c=r-r*exp((-a)*t)
hold on
title('First Order Response')
xlabel('time (s)')
ylabel ('c(t)')
plot(t,c)
end
hold off
end
& Output
% Below is the image I would like as the output but can not figure out how to aquire labels on the lines.
% Also wanting to have it not be a text box in the figure editor.
0 件のコメント
採用された回答
DGM
2022 年 11 月 30 日
編集済み: DGM
2022 年 11 月 30 日
You can use text(). You might want to adjust things a bit to help with readability.
for r = 1:1:2
for a = [0.1 0.2 0.5 0.75 1.0]
if a==0
tend=0;
else
tend=4/a;
end
t=0:1:tend;
c=r-r*exp((-a)*t);
hold on
plot(t,c)
text(t(end),c(end),sprintf('%0.1f',a),'rotation',45)
end
hold off
end
ht = title('First Order Response');
ht.Position(2) = ht.Position(2)+0.05; % make a bit more room
xlabel('time (s)')
ylabel ('c(t)')
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!