![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/708167/image.png)
Why does figure(2) keeps overwriting the previous figure?
조회 수: 28 (최근 30일)
이전 댓글 표시
I try to open figure(2) in a different window but it keeps overwriting the previous figure.
I am currently working with MATLAB R2020a.
I tried something very simple as such:
figure(1), plot([0:10],[0:10])
figure(2), plot([0:10],[10:-1:0])
figure(3), plot([0:10],rand(1,11))
figure(1) and (3) always open in a separate window but figure(2) keeps overwriting figure(1).
See attached figures
Does anyone know how to fix this?
Thank you
댓글 수: 7
Leon Hülsmann
2023년 4월 22일
I know I'm late to the party, but if you run clf at the beginning of your script, this happens for whatever reason
답변 (1개)
Sina Rangriz
2021년 8월 10일
편집: Sina Rangriz
2021년 8월 10일
use save command to see whether it is working
surf(peaks)
savefig('MySavedPlot.fig')
close(gcf)
I was running your three lines in matlab 2020b and it shows seperate figures with correct labels.
check your other parts of your code to see whether something shadows your plot
댓글 수: 2
Sina Rangriz
2021년 8월 10일
This problem is kinda weird because on my computer your attached codes working well....
figure(n) finds a figure in which the Number property is equal to n, and makes it the current figure. If no figure exists with that property value, MATLAB® creates a new figure and sets its Number property to n.
try with empty figure....like:
figure, plot([0:10],[0:10])
figure, plot([0:10],[10:-1:0])
figure, plot([0:10],rand(1,11))
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!