Having trouble assigning a handle variable to a figure with subplots

6 views (last 30 days)
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!

Accepted Answer

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!