MATLAB Answers

plot loop in a legend

1 ビュー (過去 30 日間)
INGRUS
INGRUS 2019 年 12 月 7 日
Commented: 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

  0 件のコメント

サインイン to comment.

採用された回答

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 件のコメント

INGRUS
INGRUS 2019 年 12 月 7 日
I thank you for the answer, unfortunately it is not able to write the various variables.Immagine.png
Walter Roberson
Walter Roberson 2019 年 12 月 8 日
I suspect depthmis is a 2D array.
INGRUS
INGRUS 2019 年 12 月 8 日
11*55 Array

サインイン to comment.

More Answers (0)

サインイン してこの質問に回答します。

タグ


Translated by