plot loop in a legend

4 views (last 30 days)
INGRUS
INGRUS on 7 Dec 2019
Commented: INGRUS on 8 Dec 2019
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

Accepted Answer

Walter Roberson
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
Walter Roberson
Walter Roberson on 8 Dec 2019
I suspect depthmis is a 2D array.
INGRUS
INGRUS on 8 Dec 2019
11*55 Array

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!