I define a MATLAB object class_save_test:
classdef class_save_test
methods
function b=saveobj(a)
fprintf('saveobj called.\n');
b=a;
end
end
end
When I try to save it:
j=class_save_test
save('delme1.mat','j')
I get the output
saveobj called.
saveobj called.
Why is it called twice? I have found this and this where people had the same question, but no answer :-(. I'm using Matlab 7.11.0 (R2010b).
Update: I have filed a support request with Mathworks... find their answer below :-).
According to MathWorks Technical Support:
Our current save (pre-HDF5) MAT implementation requires us to compute the size of the data on disk before actually saving the data and this cause us to go through the save process twice. This doesn't happen with HDF5 format. So doing
save('delme1.mat','j','-v7.3')
will display the message only once.
I have changed my preferences (File/Preferences/General/MAT-Files) to "MATLAB Version 7.3 or later", so now save('keepme.mat','j')
works for me :-).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With