Calling julia code from matlab

Hello everyone

I am trying to call Julia codes from MATLAB, as I need to send my Julia code to a MATLAB user.

It seems for Julia >1.0 the solution is GitHub - byuflowlab/Mex.jl: embedding Julia in the MATLAB process.

I followed the readme file: first installed MATLAB.jl from Julia and then added this Mex package in Julia by

]add GitHub - byuflowlab/Mex.jl: embedding Julia in the MATLAB process.

the readme file says this build process will build the mexjulia MEX function from the source.

But when I try jl.eval(‘2+2’) in MATLAB, it shows:

It appears the mexjulia MEX function is missing. Consider building “Mex.jl”.\n

Just to make sure MATLAB.jl is properly installed, I could do
using MATLAB
using Mex

in Julia and I am able to call mat”2+2” from Julia and get 4.0 as an output.

So it seems the mexjulia MEX function is not properly installed?

I have been following the steps and am quite confused about what I missed. I also looked through previous posts on this topic but still couldn’t figure it out.

Does anyone have some ideas about what did I miss?

Thank you very much!!

1 Like

I’m having this same issue. It looks like this fork is the most actively maintained of the Mexes, so I opened up an issue there.

Update: later I figured this was a directory issue with the Build process, the file can not locate proper location.

But even after I correct that error, the mex function call usually crashes. So I instead use Matlab call python call Julia.

Hi @Noodle, could you give a small complete example how to go the Matlab/Python/Julia route?

The search on this topic is frustrating, the development appears to have ended in 2018.
But calling Julia from Matlab should still be a hot topic, or as other posters said:

Calling Julia from Matlab, replacing mex, would be the smoothest path to sneak Julia into a company.

1 Like