How can I place labels on the end of my line plots?
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%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 commentaires
Réponse acceptée
DGM
le 30 Nov 2022
Modifié(e) : DGM
le 30 Nov 2022
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)')
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!