Hey there.
I'm trying to save a variable to file, but Matlab is acting a bit silly. When in-script I call the save function, it returns the following warning:
Warning: Variable 'result' cannot be saved to a MAT-file whose version is older than 7.3.
To save this variable, use the -v7.3 switch.
Skipping...
I've been reading the documentation and it seems it's because the file would be greater than 2 GB (which is simply not possible!). The variable in question, 'result', is a structure consisting on: result.iteration (size 100x1) method.fold (size 12x1) value(size 2x1). If all values are double, it shouldn't take more than 20 KB on disk, I think.
Anyway, following Matlab's own advice, I tried using the '-v7.3' flag, and I ended up with an enormous file of more than 5 GB in size! This makes no sense!
On the other hand, not trying to give up, I tried to directly save the variable using the contextual menu (right click on variable, 'save as...') and ended up with a more reasonable size of ~300 KB.
I have two questions regarding this issue. First, what is wrong with Matlab? And second, how can I implement in-script the same 'save as...' function as the one in the contextual menu?
Thanks a lot for your help!

8 件のコメント

Geoff Hayes
Geoff Hayes 2016 年 10 月 13 日
Françoise - out of curiosity, what is returned when you try
whos result
What is assigned to the Bytes column?
Françoise
Françoise 2016 年 10 月 13 日
Name Size Bytes Class Attributes
results 1x1 2315616 struct
Walter Roberson
Walter Roberson 2016 年 10 月 13 日
Please show the output of
FN = fieldnames(results);
for K = 1 : length(FN)
TFN = FN{K};
TF = results.(TFN);
fprintf('results.%s is class "%s" and size [', TFN, class(TF));
fprintf('%d ', size(TF));
fprintf(']\n');
end
Françoise
Françoise 2016 年 10 月 13 日
results.catId is class "double" and size [1440 100 ]
results.iter is class "struct" and size [1 100 ]
Sorry, seems I forgot about the other class. However, it still doesn't explain the 5 GB file size, does it?
Walter Roberson
Walter Roberson 2016 年 10 月 13 日
And this too please
FN = fieldnames(results.iter);
for K = 1 : length(FN)
TFN = FN{K};
TF = results.iter.(TFN);
fprintf('results.iter.%s is class "%s" and size [', TFN, class(TF));
fprintf('%d ', size(TF));
fprintf(']\n');
end
Françoise
Françoise 2016 年 10 月 13 日
results.iter.grImageId is class "double" and size [240 6 ]
Walter Roberson
Walter Roberson 2016 年 10 月 13 日
Hmmm, there is no obvious reason why that structure could not be easily saved.
Wait... I just noticed the message you posted is about variable 'result' and what you have shown us is about variable 'results' . Is it possible that you have a different variable 'result' that is not at all the same?
Françoise
Françoise 2016 年 10 月 13 日
Hmm, it's true! I just noticed that there was a similar variable named 'result', as in singular. Geez, nice coding. I think this was the problem. This variable is storing lots of unnecessary data; its size is 12 GB or something.
So sorry, in the end it was just a confusion in the variable name. But thanks a lot for your help!

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

 採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 13 日

0 投票

(wrong variable was being saved due to user typo)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePerformance and Memory についてさらに検索

タグ

質問済み:

2016 年 10 月 13 日

回答済み:

2016 年 10 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by