フィルターのクリア

changing titles for subplots in a for loop

7 ビュー (過去 30 日間)
mehra
mehra 2019 年 12 月 24 日
コメント済み: mehra 2019 年 12 月 24 日
hello
I have a code like this
for s=1:8;
r=[16,81,22,87,25,90,26,91];
subplot(4,2,s)
plot(tf,Js(1:length(tf),r(s)));
xlabel('$t_f$','interpreter','latex')
ylabel('$J$','interpreter','latex')
end
and I want the following titles for each subplot
x/D=1,z/h=0.13 , x/D=1,z/h=0.8
x/D=4,z/h=0.13 , x/D=4,z/h=0.8
x/D=8,z/h=0.13 , x/D=8,z/h=0.8
x/D=12,z/h=0.13 , x/D=12,z/h=0.8
what is the best way for that?
thanks

採用された回答

Adam Danz
Adam Danz 2019 年 12 月 24 日
Use sprintf() to define the subplot titles.
titleRows = repmat([1;4;8;12],1,2).'; % x/D values
titleCols = repmat([0.13, 0.8],4,1).'; % z/h values
for s=1:8
r=[16,81,22,87,25,90,26,91];
subplot(4,2,s)
plot(tf,Js(1:length(tf),r(s)));
xlabel('$t_f$','interpreter','latex')
ylabel('$J$','interpreter','latex')
title(sprintf('x/D=%.0f, z/h=%.2f',titleRows(s),titleCols(s)))
end
  1 件のコメント
mehra
mehra 2019 年 12 月 24 日
thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by