필터 지우기
필터 지우기

Saving and loading class member variables without temporaries

조회 수: 6 (최근 30일)
William
William 2013년 3월 14일
I have a class for which I would like to save and load specific member variables. Currently I do it as follows:
% save member variables
var1 = obj.var1;
var2 = obj.var2;
var3 = obj.var3;
save(filename,'var1','var2','var3');
% load member variables
obj = MyObject;
mvars = load(filename,'var1','var2','var3');
obj.var1 = mvars.var1;
obj.var2 = mvars.var2;
obj.var3 = mvars.var3;
The '-struct' option appears to have been added so that this can be done with structs, but it doesn't work with classes (despite it being the same notation). Is there anyway to do this without creating all of these temporaries?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by