Loop multiple plots single figure 3D matrix

Does anybody know how I can write the following commands in a loop
figure
hold on
plot(gjG(11,:,1));
plot(gjG(11,:,2));
plot(gjG(11,:,3));
plot(gjG(11,:,4));
plot(gjG(11,:,5));
plot(gjG(11,:,6));
hold off
gjG is an 11x8x6 matrix.

 採用された回答

Sean de Wolski
Sean de Wolski 2013 年 5 月 8 日
編集済み: Sean de Wolski 2013 年 5 月 8 日

0 投票

figure
hold on
for ii = 1:6
plot(gjG(11,:,ii));
end
hold off

4 件のコメント

Karl
Karl 2013 年 5 月 8 日
Thanks!
Karl
Karl 2013 年 5 月 8 日
編集済み: Karl 2013 年 5 月 8 日
A follow up question:
gjG is one of several variables i wish to make this figures for. I tried to loop over the different variablenames, but it does'n seem to work. I tried the following:
Vars = {'GjG', 'gjR', 'gjI', 'gjDI', 'gjBV', 'RtoDIplusR', 'RtoDIplusR', 'DItoG', 'RtoG', 'GtoI'};
n = length(Vars);
for iVars = 1:n;
aVars = Vars{iVars};
figure
hold on
for i = 1:6
plot(aVars(11,:,i));
end
hold off
end
Sean de Wolski
Sean de Wolski 2013 年 5 月 8 日
Vars contains strings for the names of the variables, not the variables themselves.
Vars = {GjG,gjR,etc...}
Karl
Karl 2013 年 5 月 8 日
Thanks, again :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by