Why we do defined objects are saved as unit32 in .mat files ?

In other words, how to save them as objects ?
Thanks

9 Comments

Please post any details: How do you save what in which kind of file?
Hello Jan
I have created a handle class called "Service", which just contains some properties.
Then I have done some processing to an array of Service Objects. When I save and then load from .mat file, it returns for example 291x1 uint32, although its 4x64 ServiceClass. So any help?
Jan
Jan on 14 Dec 2017
Edited: Jan on 14 Dec 2017
Please post the command you used for saving. Which MAT file format are you using? This can be defined in the Preferences. Older MAT file formats might convert the objects to byte streams - but I cannot imagine, where UINT32 is coming from. Maybe you can provide such a MAT file here?
I just save all the workspace or save('test.mat', 'RListOfDAOs', '-append');
I am using matlab 2015
When you try to load the data, is the class definition file for your object available to MATLAB? Is it on the path?
Do you receive any warning when you load your data, and if so what is the full text of that warning? [If you do remember receiving a warning but turned some or all warnings off, turn the warnings back on them load the data to see the text of the warning.]
Which path ?
Warning: Variable 'ServiceObj' originally saved as a ServiceClass cannot be instantiated as an object and will be read in as
a uint32.
> In uiimport/runImportdata (line 450)
In uiimport/gatherFilePreviewData (line 429)
In uiimport (line 246)
Warning: Variable 'ServiceObjNext' originally saved as a ServiceClass cannot be instantiated as an object and will be read
in as a uint32.
Ahhh. This message is very useful. Didn't you see it before or did you not post it, because you thought it is not important?
The "path" means Matlab's path command: All folders included in Matlab's path. Type this in the command window:
path
I thought its not important. Yeah I typed
path
I have found the parent Directory for Class there. So why still this is a problem ?
Thanks :)
Yeah I got it. The main problem is that the class was on another path. So I import the data, then it is saved to uint32 then I run the class.
So it was sorted out using the following: 1- Add path by either manually (addpath command) or by running the class file 2- Load the .mat file
But every time I run the file, I should add the path, how to add path permanently ?

Sign in to comment.

Answers (1)

how to add path permanently
addpath D:\MFiles\YourFolder -end
savepath
Look in the documentation of addpath: https://www.mathworks.com/help/matlab/ref/addpath.html. At the bottom you find the "See also" line, which contains useful related commands. Here the gem savepath is mentioned.
Alternatively you can do this using the pathtool: Select the folder in a GUI and save the path permanently.
Sometimes there are problems saving the path, if the user does not work with admin privileges (but this is a good idea!). Then writing to matlabroot\toolbox\local\pathdef.m does not work. I solve this by allowing users to modify this file in the Window Explorer.

Categories

Asked:

on 14 Dec 2017

Edited:

on 15 Dec 2017

Community Treasure Hunt

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

Start Hunting!