| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
b = saveobj(a)
b = saveobj(a) is called by the save function if the class of a defines a saveobj method. save writes the returned value, b, to the MAT-file.
Define a loadobj method to take the appropriate action when loading the object.
If A is an array of objects, MATLAB invokes saveobj separately for each object saved.
Call the superclass saveobj method from the subclass implementation of saveobj with the following syntax:
classdef mySub < super methods function sobj = saveobj(obj) % Call superclass saveobj method sobj = saveobj@super(obj); % Perform subclass save operations ... end ... end ... end
See Saving and Loading Objects from Class Hierarchies.
Update object when saved:
function b = saveobj(a) % If the object does not have an account number, % call method to add account number to AccountNumber property if isempty(a.AccountNumber) a.AccountNumber = getAccountNumber(a); end b = a; end
See Example — Maintaining Class Compatibility.
![]() | saveas | savepath | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |