Spawning Matlab processes from within Matlab
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
--How do I make Matlab call lots of little Matlabs?--
Here is a simple script that takes one parameter as input.
% simple.m  
disp(['you passed in',num2str(x)])
disp(['its cube is',num2str(x^3)])
I can run this from the command line
mymachine$ /Applications/MATLAB_R2010b.app/bin/matlab -nodisplay -nosplash -r "x=5;simple;exit"
What I would like is a way to call this script several times from within MATLAB thereby spawning independent MATLAB processes.
I had hoped it would be as simple as this:
% Control script
% Loop over an input variable and create several MATLABs
for param = 1:5
  funcstr = '/Applications/MATLAB_R2010.app/bin/matlab -nodisplay -nosplash -r ';
  scrstr = ['"x=',num2str(param),';simple;exit"'];
  command = [funcstr, scrstr];
  system(command);
end
But this seems to complete the commands sequentially rather than allowing them to run independently.
I would also rather avoid doing the control loop in a shell script if I can avoid it. Doing the loop in Matlab seems to afford me much more flexibility.
Any advice on how to do this very simple thing without the toolbox?
Cheers, John
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 14 de Nov. de 2012
        You need to have your command string "command" end with ampersand (&)
For example,
system('date &');
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Performance and Memory en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!