Install MATLAB-Engine for Julia on Apple Silicon M-series chip
The method was only tested with MATLAB R2021b and Julia 1.8.3.
MATLAB.jl
only supports R2021b until now from
official doc.
Issues with MATLAB Engine on Apple Silicon
Because MATLAB are still running on x86_64
platform,
MATLAB Engine for Python or Julia is invalid on Apple Silicon native
platform. If you want to use MATLAB Engine, you can only install all the
software on x86_64
platform.
Install Homebrew via
x86_64
platform
The solution can be found from stackoverflow discuss.
Install
homebrew
viaarch-x86_64
platform1
arch --x86_64 /bin/shell -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Add
arch-x86_64
toPATH
in~/.zshrc
. byopen ~/.zshrc
and add the following line to the end of the file.The1
2alias brow='arch --x86_64 /usr/local/Homebrew/bin/brew'
alias ib='PATH=/usr/local/bin'brow
is the alias forbrew
andib
is the alias forarch-x86_64
.Add an alias to switch between
arch-x86_64
andarch-arm64
platform1
2alias a86='env arch -x86_64 zsh'
alias a64='env arch -arm64 zsh'
Install Julia via
x86_64
platform
- Install Julia via
arch-x86_64
platformhomebrew
.Wait for the installation.1
brow install julia
Install MATLAB Engine for Julia
Start Julia
ib julia
and installMATLAB
package.1
import Pkg; Pkg.add("MATLAB")
Test the availability.
The return value should be1
2
3using MATLAB
a = mxarray(Float64,5)
nrows(a)5
.
Everytime when you run Julia rememeber to add
ib julia
rather than julia
to start
Julia if you want to use MATLAB Engine.
If you only need the Julia function, I suggest to run native version of Julia on Apple Silicon.