@@ -80,11 +80,13 @@ set "MATLAB_ROOT="
8080set " MATLAB_VER = "
8181set " HAS_ENGINE_API = "
8282
83- :: Default MATLAB version to look for
84- set " MATLAB_DEFAULT_VER = R2020b"
83+ :: MATLAB R2022b is the minimum version with Python 3.10 support.
84+ :: Compatibility: R2022b (3.8-3.10), R2023a (3.8-3.10), R2023b (3.9-3.11),
85+ :: R2024a (3.9-3.11), R2024b (3.10-3.12), R2025a (3.10-3.12)
86+ set " MATLAB_MIN_VER = R2022b"
8587
8688:: Search common MATLAB install locations (all readable without admin)
87- :: Pass 1: look for the default version (R2020b) first
89+ :: Picks the latest installed version (reverse-sorted by name)
8890for %%d in (
8991 " C:\Program Files\MATLAB"
9092 " C:\Program Files (x86)\MATLAB"
@@ -94,42 +96,52 @@ for %%d in (
9496 " E:\Program Files\MATLAB"
9597 " E:\MATLAB"
9698) do (
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"
99+ if exist " %%~d " (
100+ for /f " delims=" %%r in ('dir /b /ad /o-n " %%~d \R*" 2^ > nul ') do (
101+ if not defined MATLAB_FOUND (
102+ set " MATLAB_ROOT = %%~d \%%r "
103+ set " MATLAB_VER = %%r "
104+ set " MATLAB_FOUND = 1"
105+ )
102106 )
103107 )
104108)
105109
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- )
124- )
125- )
110+ :: Check if the detected version is too old for Python 3.10+
111+ if defined MATLAB_FOUND (
112+ set " _VER_OK = "
113+ :: Extract year from version string (e.g., R2022b -> 2022)
114+ set " _MVER = !MATLAB_VER! "
115+ set " _MYEAR = !_MVER:~1 ,4 ! "
116+ set " _MSUF = !_MVER:~5 ,1 ! "
117+ :: R2022b+ required: year>2022, or year==2022 and suffix>=b
118+ if !_MYEAR! gtr 2022 set " _VER_OK = 1"
119+ if !_MYEAR! equ 2022 if /i " !_MSUF! " geq " b" set " _VER_OK = 1"
120+ if not defined _VER_OK (
121+ echo [WARNING] Found !MATLAB_VER! but it does NOT support Python 3.10+.
122+ echo This server requires Python 3.10+ and MATLAB R2022b or newer.
123+ echo .
124+ echo MATLAB Python compatibility:
125+ echo R2022b : Python 3.8, 3.9, 3.10
126+ echo R2023a : Python 3.8, 3.9, 3.10
127+ echo R2023b : Python 3.9, 3.10, 3.11
128+ echo R2024a : Python 3.9, 3.10, 3.11
129+ echo R2024b : Python 3.10, 3.11, 3.12
130+ echo R2025a : Python 3.10, 3.11, 3.12
131+ echo .
132+ echo Ignoring incompatible !MATLAB_VER! . You can upgrade MATLAB or
133+ echo provide a path to a compatible installation below.
134+ echo .
135+ set " MATLAB_FOUND = "
136+ set " MATLAB_ROOT = "
137+ set " MATLAB_VER = "
126138 )
127139)
128140
129141if not defined MATLAB_FOUND (
130- echo [WARNING] MATLAB not found in standard locations .
142+ echo [WARNING] No compatible MATLAB found (R2022b or newer required ^ ) .
131143 echo .
132- echo Enter your MATLAB installation path (e.g., C:\Program Files\MATLAB\R2020b ^ )
144+ echo Enter your MATLAB installation path (e.g., C:\Program Files\MATLAB\R2024a ^ )
133145 echo or press Enter to skip MATLAB Engine installation:
134146 echo .
135147 set /p " MATLAB_ROOT = MATLAB path: "
0 commit comments