How to have multiple plots in one figure

1 回表示 (過去 30 日間)
Panagiotis Veneris
Panagiotis Veneris 2021 年 9 月 28 日
回答済み: Image Analyst 2021 年 9 月 28 日
So, my issue is the following. Let's imagine that initially i want to run the following code:
RA = 10;
gam = 5;
maxit = 500;
for it = 1: maxit
x = .....
end
y = constant
plot (x,y)
But now, I want to do the same for RA = 5, and have both plots in the same figure. What statement can I use to achive this?
My feeling is that something like
i = [ 10 5]
for i = 1:2
if i == 1
x1 = ....
else
x2 = .....
end
end
plot(x1,y,x2,y)
Does it make sense?
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 9 月 28 日
hi
whatever code you are producing , you can always plot the results like plot(x,y) , or plot(x1,y1,x2,y2) or even more data , but each pair of x and y values must have same length. for example it works with x1,y1 having length = 100 and x2,y2 having length = 300 (or whatever)

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

回答 (1 件)

Image Analyst
Image Analyst 2021 年 9 月 28 日
To have a layout/grid of axes on a figure, use subplot().
To draw a contant line at some y value, use yline().

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by