Variable originally saved as a structure cannot be instantiated as an object and will be read in as a uint32

161 次查看(过去 30 天)
Hello,
I am trying to load a *.mat file which contains a structure. This is not working in MATLAB 2019a or 2020a. I get:
Warning: Variable 'structure_list' originally
saved as a structure cannot be instantiated as
an object and will be read in as a uint32.
and later on in my application, it errors out. I don't think "structure" is something I am missing in my path as I am able to define and operate on structures just fine. How can I load this correctly?
Edit: I can save and load other structures just fine, so my working theory is that whoever wrote this app maybe defined another "structure" class. I'm leaving this open for now in case someone has more input.
Edit2: Yeah, someone made a class and called it structure.

采纳的回答

Steven Lord
Steven Lord 2020-4-27
I'm guessing you are able to create and work with struct arrays, which is one of the built-in types in MATLAB. I suspect your edit of your question is correct, that the structure_list variable was created as an instance of a user-defined class named structure. If the definition of the structure class was not present when you tried to load it, MATLAB wouldn't know how to interpret the saved data as a structure object.
It would be like trying to turn a kitchen's worth of ingredients (the data in the MAT-file) into a cooked meal (object): easy if you have a recipe (the class definition), perhaps not so easy if you don't.
I reopened this question so that if someone else encounters this same error message in the future they can find the discussion in a search and learn the potential (IMO probable) cause.
  2 个评论
Anna Case
Anna Case 2020-4-27
Yes, I am now looking at the classdef and plan to rename it to avoid further confusion. If you don't mind, could you tell me the best practice way to add this classdef into my App Designer code?
Steven Lord
Steven Lord 2020-4-29
Once you have the class definition, you can just load or construct it as normal and use it in methods of your app, store it in properties of your app, etc.

请先登录,再进行评论。

更多回答(1 个)

Farid
Farid 2022-8-6
I got the same error just because for some reason the toolbox that was supposed to interpret the loaded file (in my case ''deep learning toolbox'') did not function correctly and didn't apear in the apps section. I fixed the problem by reinstalling it.
Good luck
  1 个评论
JEROMY HRABOVECKY
JEROMY HRABOVECKY 2023-4-18
Thanks for the explanation. In fact, a file was inadvertently removed from my file pathway, preventing a subset of data to be read in properly. I just added the folder back to the path and everything works again.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by