MATLAB: How to open multiple MATLAB/SIMULINK files using only one MATLAB session

marelliMATLABsession

In MATLAB 7.1 (R14SP3) when I use Window Explorer to browse MATLAB and SIMULINK files, I open a single, separate MATLAB session for every files I double click on.
Also, if I use a DOS script containing the matlab.exe command for executing a MATLAB script (e.g. $MATLABROOT`\bin\win32\matlab.exe -r op1 where op1.m is a MATLAB script) I open a single separate MATLAB session for each matlab.exe command. I would prefer to use a single session.

Best Answer

This enhancement has been incorporated in Release 2007a (R2007a). For previous product releases, read below for any possible workarounds:
The capability of evoking a single MATLAB session and using only that session during batch processing (DOS script) is not currently available.
To work around this issue, please consider using a Windows Scripting Host and write a VBScript file to call MATLAB. Please see below for an example:
Open a blank text file and in it, write the following code :
' callmatlab.vbs
set Matlab = WScript.CreateObject("Matlab.Application")
' first operation
Matlab.Execute( "uiwait(msgbox('Hello', 'Hello World'))" )
' second operation
Matlab.Execute( "uiwait(msgbox('World!', 'Hello World Again '))" )
' now quit MATLAB
Matlab.Quit
then save this file as callmatlab.vbs and double click it from Windows Explorer.
You will notice that a single MATLAB opens.