From: us on
janas21 <janas21(a)gmail.com> wrote in message <cf5eacac-dc2e-4bd5-9fd1-0b4269189e3f(a)k19g2000yqc.googlegroups.com>...
> Hello,
>
> I am creating a GUI. I have to create a pushbutton which when i click
> it 4 other *m files have to run simultaneously.
>
> My problem is that while i know how to do it for 1 *.m file, i do not
> know how to do it for 4.
>
> eg. for 1 *.m file i am using the code:
>
> S.pb = uicontrol('style','push',...
> 'units','pixels',...
> 'position',[240 10 100 30],...
> 'fonts',14,...
> 'str','Click',...
> 'callback',{@pb_call1});
>
> function b = pb_call(varargin) %pb_call - callback
> b=first_m_file;
> end
>
> Can you please suggest me how I can run with the same button, 4
> different .m files? (The files are in the same folder directory).
>
> Thanks
>
> best regards
> janas

well...
you certainly cannot run them simultaneously...
why not simply...

function b=pb_call(varargin) %pb_call - callback
b{1}=first_m_file;
b{2}=second_m_file;
end

us
From: Jan Simon on
Dear Janas,

> Can you please suggest me how I can run with the same button, 4
> different .m files?

This is a really rare task for a Matlab program. Are you sure the programs need to run simultaneously??
If so you have to start 4 (or at least 3 further) Matlab sessions, e.g.:
!matlab -nosplash -r NameOfTheFunction
It is not trivial to import results from another Matlab session, but it mightbe helpful to call Matlab as an automation server (see the documentation).

BTW, what happens if I start 4 threads in a C-Mex file, which call mexCallMATLAB?

However, I assume, processing the 4 functions one after the other should work except for really strange demands.

Jan
From: Bruno Luong on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <i210m6$lfi$1(a)fred.mathworks.com>...

>
> BTW, what happens if I start 4 threads in a C-Mex file, which call mexCallMATLAB?
>
> However, I assume, processing the 4 functions one after the other should work except for really strange demands.
>

Matlab is essentially monothreading (excepted some basic low level routines). My guess is that Matlab engine is thread protected, and wait one call to be finished before starting the next one.

Asking Matlab many functions to run simultaneously does not make much sense, since there is nothing really runs simultaneously.

Bruno
From: janas21 on
On Jul 19, 10:00 am, "Jan Simon" <matlab.THIS_Y...(a)nMINUSsimon.de>
wrote:
> Dear Janas,
>
> > Can you please suggest me how I can run with the same button, 4
> > different .m files?
>
> This is a really rare task for a Matlab program. Are you sure the programs need to run simultaneously??
> If so you have to start 4 (or at least 3 further) Matlab sessions, e.g.:
>   !matlab -nosplash -r NameOfTheFunction
> It is not trivial to import results from another Matlab session,but it mightbe helpful to call Matlab as an automation server (see the documentation).
>
> BTW, what happens if I start 4 threads in a C-Mex file, which call mexCallMATLAB?
>
> However, I assume, processing the 4 functions one after the other should work except for really strange demands.
>
> Jan

First of all, thanks for your replies

Dear us,

I am afraid that with this method, I can run the first m file but not
the rest ones, i got errors.

i even used the command:

set(S.pb(:),'call',{@pp_call2}); % make callbacks referred to all
the pushbuttons of GUI.

but it seems to not work when i have only 1 pushbutton in my GUI!



Dear Jan,

I am not sure i have understand what you mean by saying to use the C-
Mex.:)

Let me describe a little bit the background of the problem, I am
making a FEM model in MATLAB, the demand is all the preparations,
which in my case are 4 *.m files, creating geometry, creating the
mesh, setting DoFs, set the solver, will be made automatically, so
that the user will not have to interfere with the program but only to
get the final results. So since it is not able from 1 pushbutton, to
trigger 4 different *.m files, i can only think 2 other options.
- either create 4 pushbuttons each of them trigger each of the *.m
file or
- the pushbutton will call the first *.m file which then will call
the second *.m file etc. (--> i already tried and it seems to work).

Actually you are right it is not so necessary to be simultaneously
solved the 4 files, although the 3 first of them can be solved in this
way. my mistake :)

thanks for your reply and help both of you.

sorry for my English writing

best regards
janas

From: Jan Simon on
Dear Janas,

ok, now it is clear to me.
Simply call the 4 M-files from the callback of your button.

Using the old style string method for the callback could start several functions also:
set(ButtonHandle, 'callback', 'disp(8); disp(9); pause(1); disp(10);')
But this is less flecible then the above method.

Jan