J'ai un terrain que je mets dans une boucle comme suit:sauter légende pour le tracé de la boucle
for i=1:300
h3 = figure(3);
hold on
h3=plot(MC_Tx{:,i},MC_Ty{:,i},MC_Dx{:,i},MC_Dy{:,i},MC_Mx{:,i},MC_My{:,i})
plot(Mx_T,My_T,'-mo','MarkerEdgeColor','k','MarkerFaceColor',[.49 1 .63],'MarkerSize',5)
h3 = title('Target and Missile Trajectory');set(h3,'Interpreter','latex');
h3 = xlabel('Downrange [m]');set(h3,'Interpreter','latex');
h3 = ylabel('Altitude [m] ');set(h3,'Interpreter','latex');
grid on
h4 = figure(4);
hold on
plot(MC_Time{:,i},MC_LAMBDT{:,i},MC_Time{:,i},MC_LAMBDD{:,i})
h4 = title('$$\dot{\lambda_{T}}(t)$$ and $$\dot{\lambda_{D}}(t)$$ vs Time');set(h4,'Interpreter','latex');
h4 = ylabel('$$\dot{\lambda_{T}}(t)$$ and $$\dot{\lambda_{D}}(t)$$ [rad/s]');set(h4,'Interpreter','latex');
h4 = xlabel('Time [s]');set(h4,'Interpreter','latex');
if i == 300
h4 = legend('$$\dot{\lambda_{T}}(t)$$','$$\dot{\lambda_{D}}(t)$$');set(h4,'Interpreter','latex');
end
grid on
end
Cependant, la plupart des lignes laïcs sur l'autre et je peux voir que 1 d'entre eux qui est les derniers.
Comment puis-je activer la légende uniquement pour la dernière ligne (ce qui signifie pour i = 300) tout en ayant quelques chiffres dans la boucle?
Merci!
Qu'en est-il d'un test if dans votre boucle for? – m7913d
C'est en fait une option! Vous vous demandez s'il y a une autre option tho – Ben