필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

question regarding figures in ploting graphs or surface

조회 수: 1 (최근 30일)
Sushanth Manchikatla
Sushanth Manchikatla 2020년 6월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
If I have created two or more figures, say figure 1,2,3.. in matlab, and each of them has a surface or any graph plotted in them. So If I want to create a new plot without creating a new figure, the new plot is plotted in the nth/ last figure. what do I do if I want the final plot to be in the first figure?

답변 (1개)

madhan ravi
madhan ravi 2020년 6월 2일
Use hold on and use plot(...) inside figure(1)
  댓글 수: 2
Steven Lord
Steven Lord 2020년 6월 2일
Be careful referring to figures by number. If someone had a figure already open before running the code that tries to plot into the "first figure" that "first figure" might not be figure number 1. Like referring to gcf or gca this is something that's probably okay to do when experimenting in the Command Window but you may want to be stricter in a function.
When you create the "first figure", store its handle in a variable that's going to be accessible to the code that creates the last plot. Use that handle (or perhaps a handle to the axes contained in it) to plot that last plot.
a = gobjects(1, 4);
for r = 1:4
a(r) = subplot(2, 2, r);
end
[x, y, z] = peaks;
surf(a(3), x, y, z); % Make certain this surface is shown in subplot 3
madhan ravi
madhan ravi 2020년 6월 2일
Yes that’s a robust approach , thanks Steven!

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by