Programming and Data Types    

Saving and Loading Function Handles

You can use the MATLAB save and load functions to save function handles to MAT files, and then load them back into your MATLAB workspace later on. This example shows an array of function handles saved to the file, savefile, and then restored.

Possible Effects of Changes Made Between Save and Load

If you load a function handle that you saved in an earlier MATLAB session, the following conditions could cause unexpected behavior:

In the first two cases, the function handle is now invalid, since it no longer maps to any existing source code. Although the handle is invalid, MATLAB still performs the load successfully and without displaying a warning. An attempt to evaluate the handle however results in an error.


  Testing for Data Type Handling Error Conditions