JuliaInterop / MATLAB.jl

Calling MATLAB in Julia through MATLAB Engine
MIT License
270 stars 63 forks source link

MATLAB.jl seems working fine with MATLAB R2023b on macOS #223

Open wsshin opened 4 months ago

wsshin commented 4 months ago

It seems that we will need to change the warning message in README.md about the MATLAB.jl package's incompatibility with the up-to-date MATLAB versions, at least for macOS running on Macs equipped with M-chips (a.k.a. Apple silicon).

For MATLAB R2023b, MathWorks released a version native to Apple silicon. Today I was able to install it on my MacBook Pro with an M3 Max chip, and it seems working fine with the MATLAB.jl package. I have verified this by running several examples in README.md. For example,

julia> VERSION
v"1.10.1"

(@v1.10) pkg> st MATLAB
Status `~/.julia/environments/v1.10/Project.toml`
  [10e44e05] MATLAB v0.8.4 `~/code/MATLAB`

julia> using MATLAB

julia> x = -10.0:0.1:10.0
-10.0:0.1:10.0

julia> y = -10.0:0.1:10.0
-10.0:0.1:10.0

julia> xx, yy = mxcall(:meshgrid, 2, x, y)
([-10.0 -9.9 … 9.9 10.0; -10.0 -9.9 … 9.9 10.0; … ; -10.0 -9.9 … 9.9 10.0; -10.0 -9.9 … 9.9 10.0], [-10.0 -10.0 … -10.0 -10.0; -9.9 -9.9 … -9.9 -9.9; … ; 9.9 9.9 … 9.9 9.9; 10.0 10.0 … 10.0 10.0])

If there are any specific corner cases that concern the developers of this package in claiming the compatibility, I can test them, so please poset the code is this thread.

bolognam commented 1 month ago

I have not tried to delve into this, but quickly trying to ]add MATLAB on a non-native MATLAB 2024a install on an M1 Max chip for Julia v1.10.4:

ERROR: Error building `MATLAB`: 
[ Info: Detected MATLAB root folder at "/Applications/MATLAB_R2024a.app"
[ Info: Detected MATLAB executable at "/Applications/MATLAB_R2024a.app/bin/matlab"
ERROR: LoadError: could not load library "/Applications/MATLAB_R2024a.app/bin/maca64/libmx"
dlopen(/Applications/MATLAB_R2024a.app/bin/maca64/libmx.dylib, 0x0001): tried: '/Applications/MATLAB_R2024a.app/bin/maca64/libmx.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Applications/MATLAB_R2024a.app/bin/maca64/libmx.dylib' (no such file), '/Applications/MATLAB_R2024a.app/bin/maca64/libmx.dylib' (no such file)
Stacktrace:
 [1] dlopen(s::String, flags::UInt32; throw_error::Bool)
   @ Base.Libc.Libdl ./libdl.jl:117
 [2] dlopen (repeats 2 times)
   @ ./libdl.jl:116 [inlined]
 [3] dlpath(libname::String)
   @ Base.Libc.Libdl ./libdl.jl:240
 [4] top-level scope
   @ ~/.julia/dev/MATLAB/deps/build.jl:81
 [5] include(fname::String)
   @ Base.MainInclude ./client.jl:489
 [6] top-level scope
   @ none:5
in expression starting at /Users/mbologna/.julia/dev/MATLAB/deps/build.jl:78

When I have more time, I would like to dig into this.

wsshin commented 1 month ago

Yes, I confirm that MATLAB.jl works with MATLAB 2023 on Apple Silicon only if you use MATLAB native to Apple Silicon. If you use MATLAB built for Intel CPUs and run it via Rosetta on Apple Silicon, MATLAB.jl doesn't work.