add legend after a loop
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
KSSV
am 8 Apr. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!