Object Data get lost between save and load

7 visualizzazioni (ultimi 30 giorni)
Johannes Kistner
Johannes Kistner il 18 Apr 2020
Risposto: Johannes Kistner il 28 Apr 2020
I want to save an object in a *.mat file and load it at a later point. Before I save it there is data in the object data property, when I load it there is no data in it. If I run this code
info1 = 'these are the properties that will be saved'
tmtable = app.FlightMatrixTable % to be saved
save('FMtestmatrix.mat','tmtable'); % saving it according to MATLAB Syntax
load('FMtestmatrix.mat'); % loading it without anything modified on tmtable between save and load
info2 = 'this is how it comes out of the mat file'
tmtable
this is the output shown in my command window:
info1 =
'these are the properties that will be saved'
tmtable =
Table with properties:
Data: [8×8 table]
ColumnWidth: 'auto'
ColumnEditable: []
CellEditCallback: ''
Position: [18 51 669 429]
Units: 'pixels'
Show all properties
info2 =
'this is how it comes out of the mat file'
tmtable =
Table with properties:
Data: []
ColumnWidth: 'auto'
ColumnEditable: []
CellEditCallback: ''
Position: [18 51 669 429]
Units: 'pixels'
Show all properties
As you can see the Data property contains an 8x8 table before saving and is empty after loading. What happened inbetween saving and loading? Thank you very much for your help!

Risposte (2)

Prabhan Purwar
Prabhan Purwar il 23 Apr 2020
Hi,
Could you please provide the app.FlightMatrixTable object so that we can replicate the issue.
Kindly refer to the following code:
info1 = 'these are the properties that will be saved'
pcobj=pointCloud([0 0 0])
save('FMtestmatrix.mat','pcobj'); % saving it according to MATLAB Syntax
load('FMtestmatrix.mat'); % loading it without anything modified on pcobj between save and load
info2 = 'this is how it comes out of the mat file'
pcobj
Output (as expected):
Thanks

Johannes Kistner
Johannes Kistner il 28 Apr 2020
I found a solution myself. As you can see in the command window output, I tried to save a 8x8 table as property. Appearently this is causing a problem, as any value is still sticked to a var name value (maybe this is general Matlab knowledge, but I did not know that). Inserting the following code solved my problem:
tmtable.Data = table2cell(tmtable.Data);

Community Treasure Hunt

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

Start Hunting!

Translated by