I have a Simulink model that, before starting, execute a script (in the callback) (let's call the script constants.m
) to set various constants and parameters in the base workspace. Now, I would like the Simulink model to be executed with various set of constants and parameters (i.e. having multiple files, constants1.m
, constants2.m
, etc.) That would remove the need to manually change the same script each time before running the Simulink model.
I was able to set a script (batchProcessing.m
), that load, execute and close the model multiple times. However, I would like to have all the jobs to run simultaneously on various cores (I have a Xeon CPU with 12 cores). Would it be possible to do this without the Parallel Toolbox? Would it be possible with a batch script (.bat
)?
Update:
Here what i tried with the help of macduff answer :
My test function :
function test3(n, ii)
A = rand(n);
B = rand(n);
tic; C=A*B;
tableTitle = {'Resultat'};
fileID = fopen(strcat('D:\Documents\MATLAB', '\', 'batchResults', num2str(ii), '.txt'),'w');
fprintf(fileID, '%12s\n', tableTitle{1});
fprintf(fileID, '%12.5f\n',C(1:10));
fclose(fileID);
toc
end
The .bat file :
set MATLAB_EXE_PATH = "C:\MATLAB\R2010a\bin\matlab.exe"
start /MIN /LOW "MATLAB" "%MATLAB_EXE_PATH%" -nosplash -nodesktop -r "test3('%100%','%1');"
start /MIN /LOW "MATLAB" "%MATLAB_EXE_PATH%" -nosplash -nodesktop -r "test3('%100%','%2');"
Nothing happens, and the .txt are not created. If I run the test3 function directly in Matlab, it works correctly. So the problem is with the batch file.
Update with correct answer
Again, with the help of macduff answer, here what i did :
set MATLAB_EXE_PATH=C:\MATLAB\R2010a\bin\matlab.exe
set arg1=5000
set arg2=1
start /MIN /LOW %MATLAB_EXE_PATH% -nodesktop -nosplash -r "cd('D:\Documents\MATLAB\'); test3(%arg1%,%arg2%); exit;"
set arg2=2
start /MIN /LOW %MATLAB_EXE_PATH% -nodesktop -nosplash -r "cd('D:\Documents\MATLAB\'); test3(%arg1%,%arg2%); exit;"
Now it would be great if the Matlab windows could stay closed and not popup on the screen.