Main Content

saveobj

객체의 저장 프로세스 수정

구문

b = saveobj(a)

설명

b = saveobj(a)a의 클래스가 saveobj 메서드를 정의하는 경우 save 함수에 의해 호출됩니다. save는 반환된 값 b를 MAT-파일에 씁니다.

객체를 불러왔을 때 적절한 작업을 수행하도록 loadobj 메서드를 정의하십시오.

A가 객체로 구성된 배열이면 MATLAB®은 저장된 각 객체에 대해 별도로 saveobj를 호출합니다.

예제

다음 구문을 사용하여 saveobj의 서브클래스 구현에서 슈퍼클래스 saveobj 메서드를 호출합니다.

classdef mySub < super
   methods
      function sobj = saveobj(obj)
         % Call superclass saveobj method
         sobj = saveobj@super(obj); 
         % Perform subclass save operations
         ...
      end
   ...
   end
...
end

저장 시 객체 업데이트:

function b = saveobj(a)
   % If the object does not have an account number,
   % Add account number to AccountNumber property
   if isempty(a.AccountNumber) 
      a.AccountNumber = getAccountNumber(a);
   end
   b = a;
end

버전 내역

R2006a 이전에 개발됨