I was wondering if it is possible to run multiple MATLAB programs at once. I would like to have one program that passively waits until a figure is open. I would like this program to be able to run at the same time as other programs that create figures and do other things while the first is waiting for a figure to be made.
Is this possible?
Thanks!
|
|
0
|
|
|
|
Reply
|
Jeff
|
6/3/2010 4:56:21 PM |
|
Dear Jeff!
> I was wondering if it is possible to run multiple MATLAB programs at once. I would like to have one program that passively waits until a figure is open. I would like this program to be able to run at the same time as other programs that create figures and do other things while the first is waiting for a figure to be made.
>
> Is this possible?
No.
But you can define a function, which is called each time a figure is created:
set(0, 'DefaultFigureCreateFunction', 'disp(''a figure is created'')');
Jan
|
|
0
|
|
|
|
Reply
|
Jan
|
6/3/2010 6:03:20 PM
|
|
Jeff Hansley wrote:
> I was wondering if it is possible to run multiple MATLAB programs at
> once. I would like to have one program that passively waits until a
> figure is open. I would like this program to be able to run at the same
> time as other programs that create figures and do other things while the
> first is waiting for a figure to be made.
>
> Is this possible?
If the first program is passively waiting for a figure to be created, then how
would the figure get created? Not by the second program: programs cannot
create Matlab figures in other programs. If your answer is that the user will
eventually take a GUI action that triggers the creation of the figure, then
that sounds like a classic use for a callback function rather than like a use
for two different programs.
|
|
0
|
|
|
|
Reply
|
Walter
|
6/3/2010 7:02:21 PM
|
|
I want one program to be able to call a variety of programs that each create an unknown number of figures. I want to be able to save every figure that is created without having to manually go into each program and save each figure.
I wasn't sure if there was a way I could put an interupt in the initial program that detects when a figure is deleted (or created) and then saves the figure.
Is this possible at all?
Thanks again,
Jeff
Walter Roberson <roberson@hushmail.com> wrote in message <hu8uaf$f2h$1@canopus.cc.umanitoba.ca>...
> Jeff Hansley wrote:
> > I was wondering if it is possible to run multiple MATLAB programs at
> > once. I would like to have one program that passively waits until a
> > figure is open. I would like this program to be able to run at the same
> > time as other programs that create figures and do other things while the
> > first is waiting for a figure to be made.
> >
> > Is this possible?
>
> If the first program is passively waiting for a figure to be created, then how
> would the figure get created? Not by the second program: programs cannot
> create Matlab figures in other programs. If your answer is that the user will
> eventually take a GUI action that triggers the creation of the figure, then
> that sounds like a classic use for a callback function rather than like a use
> for two different programs.
|
|
0
|
|
|
|
Reply
|
jhansley (2)
|
6/7/2010 7:29:04 PM
|
|
Jeff Hansley wrote:
> I want one program to be able to call a variety of programs that each
> create an unknown number of figures. I want to be able to save every
> figure that is created without having to manually go into each program
> and save each figure.
> I wasn't sure if there was a way I could put an interupt in the initial
> program that detects when a figure is deleted (or created) and then
> saves the figure.
> Is this possible at all?
It would be tricky. You would have to communicate *somehow* with the system
window manager to see when new windows had been created, and then you would
_somehow_ have to figure out when that window contained data that was ready
for you to print.
Possibly there is some Java method for doing this; possibly you might be able
to figure it out by examining the source for the Java Robot class (possibly
not... it might not care what is there.)
If there is no Java method for this, it would likely require some mex.
There is no documented Matlab method that would even allow Matlab code to
"volunteer" the information that a figure was ready to another process, let
alone a documented method by which another process could figure out what was
happening without cooperation.
Let me see... Ummm, if you could figure out the screen coordinates of all of
the close mechanisms for the figure, then _possibly_ you could use something
like the Java Robot to put very small windows transparent windows on top and
so capture the user clicking on the close request; and having done so, capture
the frame and save it off and then remove the transparent window and use the
Java Robot class to re-do the click (this time it would be received by the
original process.)
Does this definitely need to be done through different processes? In general,
such a thing would be easier done by setting the root property
'DefaultFigureCloseRequestFcn' to a callback that did the automatic saving,
unless the source sets specific CloseRequestFcn .
|
|
0
|
|
|
|
Reply
|
Walter
|
6/7/2010 7:40:52 PM
|
|
I am currently trying to interface with a GUI that creates a lot( sometimes >100 depending on settings) of plots. Since it creates so many, it automatically creates some and then saves them to a ppt file and then closes the figure. I want to interface with this and be able to open any of these plots after they are created, which would require me to save them automatically before they are closed. I can read them in from the ppt, but I lose all of the figure data that I had.
I will look into some of your suggestions, but I feel I will need to just modify the original program to just save the figures when they are created. This is just a pain because multiple different programs are called that all create some figures, so I will have to edit all of them. Not to bad, but I was just looking for a more efficient method.
Thanks for your help,
Jeff
Walter Roberson <roberson@hushmail.com> wrote in message <huji36$qap$1@canopus.cc.umanitoba.ca>...
> Jeff Hansley wrote:
> > I want one program to be able to call a variety of programs that each
> > create an unknown number of figures. I want to be able to save every
> > figure that is created without having to manually go into each program
> > and save each figure.
>
> > I wasn't sure if there was a way I could put an interupt in the initial
> > program that detects when a figure is deleted (or created) and then
> > saves the figure.
>
> > Is this possible at all?
>
> It would be tricky. You would have to communicate *somehow* with the system
> window manager to see when new windows had been created, and then you would
> _somehow_ have to figure out when that window contained data that was ready
> for you to print.
>
> Possibly there is some Java method for doing this; possibly you might be able
> to figure it out by examining the source for the Java Robot class (possibly
> not... it might not care what is there.)
>
> If there is no Java method for this, it would likely require some mex.
>
> There is no documented Matlab method that would even allow Matlab code to
> "volunteer" the information that a figure was ready to another process, let
> alone a documented method by which another process could figure out what was
> happening without cooperation.
>
>
> Let me see... Ummm, if you could figure out the screen coordinates of all of
> the close mechanisms for the figure, then _possibly_ you could use something
> like the Java Robot to put very small windows transparent windows on top and
> so capture the user clicking on the close request; and having done so, capture
> the frame and save it off and then remove the transparent window and use the
> Java Robot class to re-do the click (this time it would be received by the
> original process.)
>
>
> Does this definitely need to be done through different processes? In general,
> such a thing would be easier done by setting the root property
> 'DefaultFigureCloseRequestFcn' to a callback that did the automatic saving,
> unless the source sets specific CloseRequestFcn .
|
|
0
|
|
|
|
Reply
|
jhansley (2)
|
6/7/2010 7:58:04 PM
|
|
Jeff Hansley wrote:
> I am currently trying to interface with a GUI that creates a lot(
> sometimes >100 depending on settings) of plots. Since it creates so
> many, it automatically creates some and then saves them to a ppt file
> and then closes the figure. I want to interface with this and be able
> to open any of these plots after they are created, which would require
> me to save them automatically before they are closed. I can read them
> in from the ppt, but I lose all of the figure data that I had.
>
> I will look into some of your suggestions, but I feel I will need to
> just modify the original program to just save the figures when they are
> created.
Possibly there is a terminology difficulty here.
A "program" is something that is scheduled independently by the operating
system and has its own priority, own memory allocation, resource limits, and
so on. In this context, Matlab is the program that you are trying to write
this in, and running a different program would involve at least running a
completely different Matlab session if not a completely different program
(e.g., creating a plot in Excel.)
A "process" is fairly similar to a "program", but slightly more generalized. A
single _process_ can execute a _program_ and when that program has reached its
end, the program can replace itself by another program still using the same
_process_ . Memory gets deallocated and returned to the system when one
program replaces another in the same program, but controls such as total CPU
time or memory limits apply to processes.
Within the Matlab program, Matlab uses a threaded interpreter to execute
matlab functions. There is provision for functions to interrupt each other
through timer interrupts or callbacks, and there is provision for functions to
use multiple threads (at least if the appropriate toolbox is purchased.)
It is no so easy for a process or program to see inside of a different process
or program to see what windows are active, and it is difficult for a process
or program to see inside of a different process or program to access process
variables, and more difficult again for a process or program to see inside of
a Matlab program to get access to Workspace variables.
*If* what you are talking about is not different programs or processes but
rather different matlab functions executing within the same Matlab program,
then the DefaultFigureCloseRequestFcn would be the easiest way for you to get
a hook on those workspace variables, provided that the functions are not using
their own CloseRequestFcn (which they might.)
|
|
0
|
|
|
|
Reply
|
roberson (2852)
|
6/7/2010 8:16:58 PM
|
|
|
6 Replies
257 Views
(page loaded in 0.107 seconds)
|