Question
figure window after execution of first program should not close. when second m file is executed result of second program should be plotted in first figure window
Related Questions
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 21, 2026
The following example functions plot in the current figure window with lines held on to the same axes.
- function test1 calling test2 is completely irrelevant in this context. they can be called seperately too.
- instead of using gca you can also pass the handle of axes or figure to the other function so that it use the same to plot
- if not super imposed, you can use the subplot function to plot multiple axes on a single figure window
e.g.
function test1()
plot(1:10);
hold on;
test2();
end
function test2()
plot(gca,2:20);
end
Have a different question? Ask here