- 1 year ago
How can I associate FIG files with Matlab on Windows so that it doesn't open new copy of Matlab?
To associate FIG files with MATLAB on Windows so that it doesn't open a new copy of MATLAB each time you open a FIG file, you can create a simple batch file that checks if MATLAB is already running and opens the FIG file in the existing MATLAB instance if it is running. Here's how to do it:
Create a new text file and save it with the extension
.bat
. For example, you can name itmatlab_fig_open.bat
.Open the
.bat
file in a text editor and add the following lines:
batch@echo off
REM Check if MATLAB is already running
tasklist /FI "IMAGENAME eq matlab.exe" | find /i "matlab.exe" > nul
if %errorlevel%==0 (
REM MATLAB is running, open the FIG file in the existing instance
"C:\Program Files\MATLAB\R2021a\bin\matlab.exe" -r "open('"%1%"')"
) else (
REM MATLAB is not running, start a new instance and open the FIG file
"C:\Program Files\MATLAB\R2021a\bin\matlab.exe" -r "open('"%1%"');"
)
Replace
"C:\Program Files\MATLAB\R2021a\bin\matlab.exe"
with the actual path to your MATLAB executable. Make sure to use the correct version of MATLAB that you want to use.Save the
.bat
file.Now, right-click on a
.fig
file and choose "Open with" -> "Choose another app."Browse and select the
.bat
file you created (matlab_fig_open.bat
) and check the box "Always use this app to open .fig files."
Now, whenever you double-click on a .fig
file, it will open in the existing instance of MATLAB if it is already running. If MATLAB is not running, it will start a new instance and open the .fig
file. This way, you can avoid opening multiple instances of MATLAB when opening FIG files.