plot loop in a legend
4 views (last 30 days)
Show older comments
hi, I have a problem with a plot in a loop. I don't understand how I can plot the names of my variables.
The chart compares a fixed solution with others that vary
I would like to insert the name of the variable inside the legend for each cycle when I finish fighting, but I don't know how to do it. sorry but I'm a neophyte, I thank you in advance for your help.
for nvar =1:length(ID_var)
mat=load(['tr',ID_var{nvar},'.mat']);
Quota1=mat.Z;
n2=rot90(Quota1);
Quota=flipud(n2);
t=mat.T;
Temperatura1=squeeze(t(:,1,:,1));
for n=1:length(Dmis)
figure(n)
plot(Temperatura(:,Dmod(n)),Quota,'-')
hold on
plot(Tmis(:,Dmis(n)),-depthmis,'o');
legend({ID{nvar},'Dati misurati'},'location','northeastoutside');
drawnow;
xlabel('T[°C]')
ylabel('Z[m]')
grid on;
end
0 Comments
Accepted Answer
Walter Roberson
on 7 Dec 2019
plot(Temperatura(:,Dmod(n)),Quota,'-', 'DisplayName', ID{nvar})
hold on
plot(Tmis(:,Dmis(n)),-depthmis,'o', 'DisplayName', 'Dati misurati');
legend('show', 'location','northeastoutside');
3 Comments
More Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!