plot loop in a legend

2 次查看(过去 30 天)
INGRUS
INGRUS 2019-12-7
评论: INGRUS 2019-12-8
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

采纳的回答

Walter Roberson
Walter Roberson 2019-12-7
plot(Temperatura(:,Dmod(n)),Quota,'-', 'DisplayName', ID{nvar})
hold on
plot(Tmis(:,Dmis(n)),-depthmis,'o', 'DisplayName', 'Dati misurati');
legend('show', 'location','northeastoutside');
  3 个评论
Walter Roberson
Walter Roberson 2019-12-8
I suspect depthmis is a 2D array.
INGRUS
INGRUS 2019-12-8
11*55 Array

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by