|On this page…|
When you no longer need an instrument object, you should disconnect it from the instrument, and clean up the MATLAB® workspace by removing the object from memory and from the workspace.
To disconnect your communication with the instrument, use the fclose function.
You can examine the Status property to verify that the object and the instrument are disconnected.
g.Status ans = closed
After fclose is issued, the resources associated with g are made available, and you can once again connect an instrument object to the instrument with fopen.
To remove the instrument object from memory, use the delete function.
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.
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.