Having trouble assigning a handle variable to a figure with subplots
3 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
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)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!