Plotting multiple graphs in one figure

I want to put 3 curves in one graph but i couldn't use the hold on function because for each curve i run several times to get the values i want so any idea how to do it without the hold on function??

댓글 수: 3

Ben Mitch
Ben Mitch 2011년 5월 27일
Hi Salma - it's not clear what the problem is. What do you mean by "i run several times"? Run what? Why does that obstruct the use of "hold on"?
Salma
Salma 2011년 5월 27일
i run the code several times because the input is random
Walter Roberson
Walter Roberson 2011년 5월 27일
Please show the structure of your code. It is not clear why "hold on" would not work for you.

댓글을 달려면 로그인하십시오.

답변 (4개)

Jan
Jan 2011년 5월 27일

1 개 추천

If you want to avoid "hold on" for any reasons (which I cannot understand), try this initially:
axes('NextPlot', 'add')
Samer Husam
Samer Husam 2012년 8월 30일

1 개 추천

try this:
curve 1: x1,y1
curve 2: x2,y2
curve 3: x3,y3
figure (1)
plot(x1,y1,x2,y2,x3,y3)
Igor
Igor 2011년 5월 27일

0 개 추천

maybe
plot(gca,x1,y1)
plot(gca,x2,y2)

댓글 수: 1

Walter Roberson
Walter Roberson 2011년 5월 27일
Igor, under the default settings, the second plot would overwrite the first. Using "hold" or setting NextPlot are necessary to prevent that.

댓글을 달려면 로그인하십시오.

Walter Roberson
Walter Roberson 2011년 5월 27일

0 개 추천

If you are not specifically creating a new figure each time, then you could switch to using line() instead of plot()

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2011년 5월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by