From: Matthew C on
So I have a GUI. You press a button and it runs a for loop, each iteration of the for loop does a calculation and plots something to "Figure 1". In fact, it plots 2 subplots on Figure 1, each subplot contains a number of data sets.

My problem is when the user "closes" the figure in the middle of plots, MATLAB defaults to plotting over the GUI. I have tried different combinations of:

- getting figure handle h = figure(1);
- set(0, 'currentfigure', h) before EACH plot
- immediately after plotting the first one, I get current axis (gca) and all plot commands from therein go to that axis
etc.

Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.

Thanks.
From: us on
"Matthew C"
> Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.

well... that seems a bit ...twisted...

a hint:
- set these fig callbacks
CLOSEREQUESTFCN
DELETEFCN
to prevent a user from being able to close/delete a fig...
- don't forget to reset them when your gui closes...

us
From: us on
"us " <us(a)neurol.unizh.ch> wrote in message <hosvk9$i9c$1(a)fred.mathworks.com>...
> "Matthew C"
> > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
>
> well... that seems a bit ...twisted...
>
> a hint:
> - set these fig callbacks
> CLOSEREQUESTFCN
> DELETEFCN
> to prevent a user from being able to close/delete a fig...
> - don't forget to reset them when your gui closes...
>
> us

the exemplary code was not copy/pasted...

fdr=@(varargin) 'disp(''DELETE'');';
fcr=@(varargin) 'disp(''CLOSE'');';
fh=figure(...
'closerequestfcn',fcr(),...
'deletefcn',fdr(),...
'handlevisibility','on'); % <- invisible to CLOSE ALL...
% now, close your figure using the various mouse-options, eg,
% figure -> file -> close
% figure -> X
% also, in the command window
close all;
% however, this works when issued in the command window...
delete(fh);

us
From: Matthew C on
"us " <us(a)neurol.unizh.ch> wrote in message <hosvk9$i9c$1(a)fred.mathworks.com>...
> "Matthew C"
> > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
>
> well... that seems a bit ...twisted...
>
> a hint:
> - set these fig callbacks
> CLOSEREQUESTFCN
> DELETEFCN
> to prevent a user from being able to close/delete a fig...
> - don't forget to reset them when your gui closes...
>
> us

How do you set those call backs for a figure that is created using figure(1);?

Thanks.
From: us on
"Matthew C" <twisted_mc(a)hotmail.com> wrote in message <hot1k4$o5e$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <hosvk9$i9c$1(a)fred.mathworks.com>...
> > "Matthew C"
> > > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
> >
> > well... that seems a bit ...twisted...
> >
> > a hint:
> > - set these fig callbacks
> > CLOSEREQUESTFCN
> > DELETEFCN
> > to prevent a user from being able to close/delete a fig...
> > - don't forget to reset them when your gui closes...
> >
> > us
>
> How do you set those call backs for a figure that is created using figure(1);?
>
> Thanks.

a hint:
- put the exemplary code as shown in the last reply into the figure's
CREATEFCN callback...

us