MATLAB.jl icon indicating copy to clipboard operation
MATLAB.jl copied to clipboard

Matlab strings not supported

Open MaxandreJ opened this issue 6 years ago • 0 comments

Hi all,

This is similar to #135 but extends the issue to simple strings (1x1 string array). It wasn't obvious to me that a string behaved like a string array so maybe this should be clarified in the README.

A simple 1x1 string (which is a particular case of string array), defined and saved as such

my_test = "test";
save("../../../Data/test/test.mat",'my_test')

when imported into Julia using

my_matfile_contents = read_matfile("../../Data/test/test.mat")

my_variable_MxArray = my_matfile_contents["my_test"]

my_variable_julia = jvalue(my_variable_MxArray)

returns

ERROR: ArgumentError: Unsupported kind of variable.
Stacktrace:
 [1] jvalue(::MxArray) at /Users/maxandrejacqueline/.julia/packages/MATLAB/ZuG4g/src/mxarray.jl:610
 [2] top-level scope at none:0

and when the string is inside a struct, as such

my_test = struct;
my_test.test = "test";
save("../../../Data/test/test.mat",'my_test')

running

my_matfile_contents = read_matfile("../../Data/test/test.mat")

my_struct_MxArray = my_matfile_contents["my_test"]

my_struct_julia = jvalue(my_struct_MxArray)

returns

ERROR: NULL pointer for MxArray.
Stacktrace:
 [1] Type at /Users/maxandrejacqueline/.julia/packages/MATLAB/ZuG4g/src/mxarray.jl:8 [inlined]
 [2] Dict(::MxArray) at /Users/maxandrejacqueline/.julia/packages/MATLAB/ZuG4g/src/mxarray.jl:587
 [3] jvalue(::MxArray) at /Users/maxandrejacqueline/.julia/packages/MATLAB/ZuG4g/src/mxarray.jl:608
 [4] top-level scope at none:0

Best, Max

MaxandreJ avatar Nov 18 '18 01:11 MaxandreJ