Having trouble assigning a handle variable to a figure with subplots

2 次查看(过去 30 天)
Hello, I am still new to MATLAB and having difficulty understanding how to work with figure handles. I have a plot with subplots and multiple graphs within it and would like to pass the entire figure up through the function it is called to be displayed somewhere else only if certain conditions are met. Here is a simplified example of one figure:
x = (1:25)';
bl1 = x;
bl2 = x+3;
bl3 = x+5;
mbl1 = x.^2;
mbl2 = x.^2+3;
mbl3 = x.^2+5;
figure(3)
subplot(1,2,1);
hold on
plot(bl1)
plot(bl2,'g')
plot(bl3,'m')
title('linear')
subplot(1,2,2);
hold on
plot(mbl1)
plot(mbl2,'g')
plot(mbl3,'m')
title('square')
Any help/explanations would be greatly appreciated!

采纳的回答

Kevin Claytor
Kevin Claytor 2012-7-24
function myfig = makefigure()
% stuff
myfig = figure(3);
% stuff
end
and then
myfig = makefigure();
get(myfig,'Children');
will return the handles to all the subplots.

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by