ZeroMQ to call Julia from Matlab

Viewed 122

I need to call Julia from Matlab:

[out1, out2, ...] = jlcall(fname, arg1, arg2, ...);

Where fname is a string and all other data in a binary format known to both Matlab and Julia.

ZeroMQ implementations exist for Matlab and Julia.

Could you help with a simple ZeroMQ setup which would fit the bill?

Update: following the suggestion of Bill below, I implemented the serialization/deserialization on both sides:

% Matlab
>> data = {"sin", 1}
data =
  1×2 cell array
    {'sin'}    {[1]}
>> txt_json = jsonencode(data)
txt_json =
    '["sin",1]'
>> txt_base64 = matlab.net.base64encode(txt_json)
txt_base64 =
    'WyJzaW4iLDFd'

# Julia
julia> JSON3.read(base64decode("WyJzaW4iLDFd"))
2-element JSON3.Array{Any, Base.CodeUnits{UInt8, String}, Vector{UInt64}}:
  "sin"
 1
julia> f = Symbol(fun)
:sin
julia> @eval $f(arg)
0.8414709848078965

How to write the remaining part in ZMQ?

0 Answers
Related