Accessing Matlab-function from Julia

Hello everyone,

I recently started to work with Julia and need to evaluate some custom matlab-functions in my julia-scripts. Therefore, I added the package MATLAB.jl and updated the environment variable MATLAB_HOME to the installation directory of the matlab version I use. However, I am not able to execute any of the mentioned examples in https://github.com/JuliaInterop/MATLAB.jl .

For example, if i want to execute

using MATLAB

x = 5
mat"plot($x, sin($x))"

I get the following error-message

LoadError: UndefRefError: access to undefined reference

in expression starting at D:\UNI\Julia\test_matlab.jl:4

MSession(::Int64; flags::String) at engine.jl:26

MSession at engine.jl:23 [inlined]

MSession at engine.jl:23 [inlined]

get_default_msession at engine.jl:88 [inlined]

put_variable(::Symbol, ::Int64) at engine.jl:159

top-level scope at matstr.jl:160

include_string(::Function, ::Module, ::String, ::String) at loading.jl:1088

Moreover, I do not get this error for this example only, but for every listed example under GitHub - JuliaInterop/MATLAB.jl: Calling MATLAB in Julia through MATLAB Engine .

Any suggestions what could cause this error-message?

Best,
andre

I can not recreate your error. I got this:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.2 (2020-05-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using MATLAB

julia> x = 5
5

julia> mat"plot($x, sin($x))"
Undefined function 'sin' for input arguments of type 'int64'.

And I was able to get a MSession, it seems like you couldn’t.

julia> MATLAB.get_default_msession()
MSession(Ptr{Nothing} @0x0000000032efd420, UInt8[0x00, 0x6e, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20  …  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], Ptr{UInt8} @0x0000000033ac5f40)

I am on Windows 10, Julia 1.4.2, MATLAB.jl v0.7.3, MATLAB R2017b. And I didn’t set `MATLAB_HOME’.