JuliaInterop / MATLAB.jl

Calling MATLAB in Julia through MATLAB Engine
MIT License
270 stars 63 forks source link

mxarray on partially initialized structs #185

Open maartenvd opened 3 years ago

maartenvd commented 3 years ago

In one of the packages I use there is a struct that gets partially initialized. This makes it so mxarray fails because of :

mxarray.jl:488 set_field(mx, names_str[i], mxarray(getfield(d, names[i])))

getfield throws an error, as this field isn't defined. I'm not entirely sure how to go about fixing this. I guess you could add a new UNDEF struct in matlab.jl, check if isdefined(d,names[i]) and if not, do set_field(mx,names_str[i],mxarray(UNDEF)) (if this sounds ok I'll open a pull request).

Alternatively, I can define my own mxstruct conversions for those problematic types.