-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_variable: Unsupported variable types #135
Comments
I agree, no support for nested structs. I would really appreciate if there was support for it. |
Here is a workaround using PyCall and scipy.io. First you need to make sure that your nested structs are really structs and not user-defined classes, in which case it won't work. To transform a Matlab class into struct before exporting, run in MATLAB the command Then this is the code I used to import this nested struct into MATLAB (with Julia v1.0)
I call the functions in that code snippet using
the variables (
Hope that helps! |
can you provide a MWE ? |
Thank you for answering @musm ! Okay, I've got it! The problem isn't to do with nested structs, actually. The existence of a struct makes the bug less easy to track down though. What I've found to be the gist of the bug is that string arrays, introduced in MATLAB R2016b, are not supported by MATLAB.jl. This can be seen by running in MATLAB
then saving the variable calling it
which results in the error
Now if you nest a string array in a struct, by running the MATLAB code
save it in as
you get the error
I suggest, listing first the things that should be done in priority and that are simpler to implement:
(As an aside, I think, but I'm not entirely sure, that a similar bug exists for importing in Julia user-defined classes in MATLAB, but since scipy.io doesn't work for that either, it's not too bad... It should probably be mentionned in the README too nevertheless. I don't have any more time tonight to provide a MWE for this last point about classes so I may be wrong on that...) |
@MaxandreJ thanks for the details, indeed you are right. I was exploring the issue and basically it seems like some of the matlab api cannot deal with string arrays, which is why we get null pointers. |
Basically the current workaround is to use the matlab function |
Thank you for finding this function, yes that works perfectly! If the variable you want to export to Julia has a string array, this function should be called on the variable before saving it, either to a |
Basically this is impossible with the C engine for MATLAB, we would have to use the C++ engine instead, which is a big project, but a long term goal. |
Thanks for digging into this @musm ! Although a complete fix doesn't seem possible in the short term, I think the package could be improved by (as I said in a previous post on this thread):
or better,
Best, |
Main issue addressed by updating the readme. Thanks @maximilianpreisinger |
Thank you @musm and @maximilianpreisinger ! |
Hello Guys! I run the following piece of code:
And I get the error:
The wanted variable shows the type
1x1 SimulationOutput
in Matlab.Are you intending to add support for
SimulationOutput
variables, which you get when you run a Simulink .slx Simulation? Do you have an overview of the variable types, which you support, or which you don't support?Furthermore, when opening nested
1x1 struct
variables (I have a struct that is 4 times nested, which looks in matlab something like this: parameter.a.b.c.d = [1 0 0] for example. I get the following error:So I suppose, you also do not support nested struct variables at the moment. Will this change?
The text was updated successfully, but these errors were encountered: