I am trying to plot some functions and display a legend. My code can be found below:
figure(1)
pl = plot(Yle_wing,Clmax_dist,'r');
set(pl,'linewidth',1.5);
hold on
if iteration <= AVLruns
plot(Yle_wing,Spanloading,'g--o')
set(pl,'linewidth',1.5);
else
plot(Yle_wing,Spanloading)
end
xlabel('2y/b')
ylabel('Local Cl')
title('DATCOM SPANLOADING METHOD')
legend('boxon')
legend('2D Clmax','Spanloading by AVL','Spanloading by extrapolation','Location','southwest')
Here, I create a plot in the same figure using the hold on statement and with an if statement. Running my code will run both conditions of the if statement. Hence, multiple lines will be plotted in this Figure.
Therefore, I want to make a legend for all three plot commands. However, I don't seem to understand how to create the legend for a plot function within an if statement since the following makes my second plot green, and the rest of the plots red.
How would I go about?
Aucun commentaire:
Enregistrer un commentaire