adding legend from a list in the loop divides the names

Hi all
I want to add the six plots in one plot a legend. which I have defined as :
Ls=['L1','L2','L3','L4','L5','L6'];
for c=1:6
plot3(v(:,1),v(:,2),v(:,3),colorcode(c),'DisplayName',Ls(c))
hold on
end
when I do this , the legend gets like :

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 8 Mai 2020
Modifié(e) : Ameer Hamza le 8 Mai 2020
[ ] is concatenates the char datatypes. You need to use cell data type to keep them separate.
Ls={'L1','L2','L3','L4','L5','L6'};
for c=1:6
plot3(v(:,1),v(:,2),v(:,3),colorcode(c),'DisplayName',Ls{c})
hold on
end

7 commentaires

dear Ameer , I am stuck in a new difficult problem : here
I don't have the toolbox needed to answer that question, and I also haven't used them before, so I don't have the hands-on experience needed to suggest a solution to that problem.
pptpop() is not a tool. the mlx file exists already in Matlab installation directory
I mean, I don't have the compiler tools. pptpop also requires MATLAB report generator.
it still doesn't work in the app window yet. the problem with printPlot that I don't know if app designer supports
You mean the legend does not work correctly?
no the legend is ok, I was talking about the other question. maybe better to follow up there

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by