フィルターのクリア

How to simultanously create 2 subplots?

2 ビュー (過去 30 日間)
John
John 2017 年 5 月 9 日
コメント済み: John 2017 年 5 月 9 日
Learned from Matlab, this worked:
figure;
for k = 1:8
h(k) = subplot(2,4,k);
end
figure;
for k = 1:8
J(k) = subplot(2,4,k);
end
But when call with after:
for k = 1:8
subplot(h(k);plot(a(k))
subplot(J(k);plot(b(k))
end
It plots 4-a and 4-b on the second figure and left the first figure with 8 empty subplots. What's wrong?

採用された回答

Walter Roberson
Walter Roberson 2017 年 5 月 9 日
Your code
for k = 1:8
subplot(h(k);plot(a(k))
subplot(J(k);plot(b(k))
end
is not valid syntax: you cannot have a ";" at that position in the line and you are missing a ")" on each line.
You should be using
for k = 1:8
plot(h(k), a(k), '*')
plot(J(k), b(k), '*')
end
I added the '*' because you are only plotting a single point, and when you only plot a single point it will not show up unless you specify a marker.
  1 件のコメント
John
John 2017 年 5 月 9 日
Thanks, Walter! Above was a typo, code was correct. That code is from 'doc subplot' and works for single subplot figure.

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

その他の回答 (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