Skip to content

Commit 966d1cb

Browse files
HanSur94claude
andcommitted
fix: default MATLAB detection to R2020b in install.bat
Search for R2020b first before falling back to the latest installed MATLAB version. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 661a6da commit 966d1cb

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

install.bat

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ set "MATLAB_ROOT="
8080
set "MATLAB_VER="
8181
set "HAS_ENGINE_API="
8282

83+
:: Default MATLAB version to look for
84+
set "MATLAB_DEFAULT_VER=R2020b"
85+
8386
:: Search common MATLAB install locations (all readable without admin)
87+
:: Pass 1: look for the default version (R2020b) first
8488
for %%d in (
8589
"C:\Program Files\MATLAB"
8690
"C:\Program Files (x86)\MATLAB"
@@ -90,12 +94,33 @@ for %%d in (
9094
"E:\Program Files\MATLAB"
9195
"E:\MATLAB"
9296
) do (
93-
if exist "%%~d" (
94-
for /f "delims=" %%r in ('dir /b /ad /o-n "%%~d\R*" 2^>nul') do (
95-
if not defined MATLAB_FOUND (
96-
set "MATLAB_ROOT=%%~d\%%r"
97-
set "MATLAB_VER=%%r"
98-
set "MATLAB_FOUND=1"
97+
if not defined MATLAB_FOUND (
98+
if exist "%%~d\%MATLAB_DEFAULT_VER%" (
99+
set "MATLAB_ROOT=%%~d\%MATLAB_DEFAULT_VER%"
100+
set "MATLAB_VER=%MATLAB_DEFAULT_VER%"
101+
set "MATLAB_FOUND=1"
102+
)
103+
)
104+
)
105+
106+
:: Pass 2: if R2020b not found, fall back to the latest installed version
107+
if not defined MATLAB_FOUND (
108+
for %%d in (
109+
"C:\Program Files\MATLAB"
110+
"C:\Program Files (x86)\MATLAB"
111+
"%USERPROFILE%\MATLAB"
112+
"D:\Program Files\MATLAB"
113+
"D:\MATLAB"
114+
"E:\Program Files\MATLAB"
115+
"E:\MATLAB"
116+
) do (
117+
if exist "%%~d" (
118+
for /f "delims=" %%r in ('dir /b /ad /o-n "%%~d\R*" 2^>nul') do (
119+
if not defined MATLAB_FOUND (
120+
set "MATLAB_ROOT=%%~d\%%r"
121+
set "MATLAB_VER=%%r"
122+
set "MATLAB_FOUND=1"
123+
)
99124
)
100125
)
101126
)
@@ -104,7 +129,7 @@ for %%d in (
104129
if not defined MATLAB_FOUND (
105130
echo [WARNING] MATLAB not found in standard locations.
106131
echo.
107-
echo Enter your MATLAB installation path (e.g., C:\Program Files\MATLAB\R2024a^)
132+
echo Enter your MATLAB installation path (e.g., C:\Program Files\MATLAB\R2020b^)
108133
echo or press Enter to skip MATLAB Engine installation:
109134
echo.
110135
set /p "MATLAB_ROOT= MATLAB path: "

0 commit comments

Comments
 (0)