How to have multiple plots in one figure
4 views (last 30 days)
Show older comments
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 Comment
Mathieu NOE
on 28 Sep 2021
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)
Answers (1)
Image Analyst
on 28 Sep 2021
To have a layout/grid of axes on a figure, use subplot().
To draw a contant line at some y value, use yline().
0 Comments
See Also
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!