Azzera filtri
Azzera filtri

Having trouble assigning a handle variable to a figure with subplots

4 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Kevin Claytor
Kevin Claytor il 24 Lug 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.
  1 Commento
Jessica
Jessica il 24 Lug 2012
Modificato: Jessica il 24 Lug 2012
I was misunderstanding the way handles work, this helps, thank you!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by