Disconnecting and Cleaning Up
Disconnecting an Instrument Object
When you no longer need to communicate with the instrument, you should disconnect
the object. Interface objects are disconnected with the fclose
function; device objects
are disconnected with the disconnect
function.
You can examine the Status
property to verify that the object
is disconnected from the instrument.
obj.Status
ans = closed
Cleaning Up the MATLAB Workspace
When you no longer need the instrument object, you should remove it from memory
with the delete
function.
delete(obj)
A deleted instrument object is invalid, which means that you
cannot connect it to the instrument. In this case, you should remove the object from
the MATLAB® workspace. To remove instrument objects and other variables from the
MATLAB workspace, use the clear
command.
clear obj
If you use clear
on an object that is connected to an
instrument, the object is removed from the workspace but remains connected to the
instrument. You can restore cleared instrument objects to the MATLAB workspace with the instrfind
function.