Saving Your Work

Functions for Saving and Restoring COM Objects

Use these MATLAB® functions to save and restore the state of a COM control object.

FunctionDescription

load

Load and initialize a COM control object from a file

save

Write and serialize a COM control object to a file

Save, or serialize, the current state of a COM control to a file using the save function. Serialization is the process of saving an object onto a storage medium (such as a file or a memory buffer) or transmitting it across a network connection link in binary form.

The following example creates an mwsamp2 control and saves its original state to the file mwsample:

f = figure('position', [100 200 200 200]);
h = actxcontrol('mwsamp.mwsampctrl.2', [0 0 200 200], f);
h.save('mwsample')

Now, alter the figure by changing its label and the radius of the circle:

h.Label = 'Circle';
h.Radius = 50;
h.Redraw;

Using the load function, you can restore the control to its original state:

h.load('mwsample');

To verify the results, type:

h.get

MATLAB displays:

ans = 
     Label: 'Label'
    Radius: 20

Releasing COM Interfaces and Objects

Use these MATLAB functions to release or delete a COM object or interface.

FunctionDescription

delete

Delete a COM object or interface

release

Release a COM interface

When you no longer need an interface, use the release function to release the interface and reclaim the memory used by it. When you no longer need a control or server, use the delete function to delete it. Alternatively, you can use the delete function to both release all interfaces for the object and delete the server or control.

When you delete or close a figure window containing a control, MATLAB automatically releases all interfaces for the control. MATLAB also automatically releases all handles for an Automation server when you exit the program.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS