开发者

Why does MATLAB save() call saveobj() twice?

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 sa开发者_如何转开发me 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 :-).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜