Try to save structural variable, but not everything is saved

2 ビュー (過去 30 日間)
Xh Du
Xh Du 2017 年 8 月 3 日
コメント済み: Xh Du 2017 年 8 月 3 日
Hi all,
I ran my code for a few hours and now I get some results. I'd like to save these data to a .mat file such that I can open and edit it later. My data looks like this:
>> canti
canti =
canbeam with properties:
cons: [1x1 struct]
fce: [1x1 struct]
err: [1x1 struct]
countGreedy: 30
refinement: [1x1 struct]
pmExpo: [1x1 struct]
resp: [1x1 struct]
indicator: [1x1 struct]
sti1: [1x1 struct]
sti2: [1x1 struct]
stis: [1x1 struct]
asemb: [1x1 struct]
str: [1x1 struct]
node: [1x1 struct]
elem: [250x4 double]
domLeng: [1x1 struct]
domBond: [1x1 struct]
pmComb: []
pmVal: [1x1 struct]
pmLoc: [1x1 struct]
pmGrid: [1x1 struct]
time: [1x1 struct]
phi: [1x1 struct]
coef: []
draw: []
imp: [1x1 struct]
qoi: [1x1 struct]
mas: [1x1 struct]
dam: [1x1 struct]
sti: [1x1 struct]
acc: [1x1 struct]
vel: [1x1 struct]
dis: [1x1 struct]
no: [1x1 struct]
The entire canbeam should be around half a gigabyte. I tried to save like this:
>> save('l9h2.mat', 'a')
However, the saved .mat file is only 210 bytes, obviously not saving everything. How can I save all data in canbeam to a file? What is the best way to save data for future use?
Thanks!
EDIT: what I did was actually
>> save('l9h2.mat', 'canti')
My bad!
  2 件のコメント
Stephen23
Stephen23 2017 年 8 月 3 日
>> canti
canti =
canbeam with properties:
Is canbeam an instance of a MATLAB class? Or is this a third-party class?
Xh Du
Xh Du 2017 年 8 月 3 日
Hi, it's a class defined by myself, so I guess it's third party?
canti is the handle itself, so only 112 bytes, but few days ago I actually saved the entire "canti" including it's structural contents by using
>> save('l9h2.mat', 'canti')

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 8 月 3 日
You are asking to save only the variable 'a', not the variable 'canti'
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 8 月 3 日
Hmmm, I guess only a handle got saved, without the content that the handle was referring to. I do not know what to do about that.
Xh Du
Xh Du 2017 年 8 月 3 日
It's weird, the first time I saved 'canti', it actually saved everything (the saved .mat file was 410.4 MB), if I load it, it looks like this:
>> varload = load('l9h2_t100_f6_dom17*17_plot2*5_init[1_5]_ref_001_qoi5_10_proposed.mat');
>> varload
varload =
canti: [1x1 canbeam]
>> varload.canti
ans =
canbeam with properties:
cons: [1x1 struct]
fce: [1x1 struct]
err: [1x1 struct]
countGreedy: 10
refinement: [1x1 struct]
pmExpo: [1x1 struct]
resp: [1x1 struct]
indicator: [1x1 struct]
sti1: [1x1 struct]
sti2: [1x1 struct]
stis: [1x1 struct]
asemb: [1x1 struct]
str: [1x1 struct]
node: [1x1 struct]
elem: [250x4 double]
domLeng: [1x1 struct]
domBond: [1x1 struct]
pmComb: []
pmVal: [1x1 struct]
pmLoc: [1x1 struct]
pmGrid: [1x1 struct]
time: [1x1 struct]
phi: [1x1 struct]
coef: []
draw: []
imp: [1x1 struct]
qoi: [1x1 struct]
mas: [1x1 struct]
dam: [1x1 struct]
sti: [1x1 struct]
acc: [1x1 struct]
vel: [1x1 struct]
dis: [1x1 struct]
no: [1x1 struct]

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by