plot loop in a legend

4 ビュー (過去 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 Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by