add legend after a loop
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
im bulding a program that finds the roots' the last number change from 0 to 20. after that im plot the result' and i want to add legend for each result. im probably getting complex numbers.
clear all;
close all;
Legend=cell(19,1)
for k=0:20
p=[1 2 4 k]
r=roots(p);
figure(1)
hold on;
plot(r,'*')
hold on;
end
axis ([-3.5 0.7, -3 3])
grid on;
plot( 0, [-3:0.01:3],'k.-')
hold off;
xlabel('Re(s)')
ylabel('Im(s)')
title('system poles with diffeent k')
0 commentaires
Réponses (1)
KSSV
le 8 Avr 2022
May be something like below:
figure(1)
hold on
for k=0:20
p=[1 2 4 k] ;
r=roots(p);
plot(r,'*','DisplayName',num2str(k))
end
axis ([-3.5 0.7, -3 3])
grid on;
plot( 0, [-3:0.01:3],'k.-','DisplayName','out of loop')
hold off;
xlabel('Re(s)')
ylabel('Im(s)')
title('system poles with diffeent k')
legend show
0 commentaires
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!