I make plots in the main part of my scripts but I also do plotting from functions. It appears that when I call a function, gcf does not have to be passed as an argument, i.e., it appears as though gcf is some sort of global variable. I say "appears" because some times gcf doesn't seem to get updated and a plot from within a function will wipe out a previously generated figure from the main script. Can someone point me to some documentation that will clear this up for me?
Below is a sketch of the kind of thing I am trying to do. When I try passing gcf as an argument I still get inconsistent results.
% main part of script
t=0:100; y=sin(2*pi*t/20); figure(1); plot(t,y); dummy=RoutineThatDoesPlotting(t,y);
….. % end of script
function dummy=RoutineThatDoesPlotting(t,y); figure(gcf+1); plot(t,y); dummy=1; % end of function
Thanks for your help.
Dave
Best Answer