How to have multiple plots in one figure
조회 수: 8 (최근 30일)
이전 댓글 표시
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
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
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().
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!