delete (serial)
Remove serial port object from memory
Syntax
delete(obj)
Description
delete(obj)
removesobj
from memory, whereobj
is a serial port object or an array of serial port objects.
Examples
This example creates the serial port objects
on a Windows®platform, connectss
to the device, writes and reads text data, disconnectss
from the device, removess
from memory usingdelete
, and then removess
from the workspace usingclear
.
s = serial('COM1'); fopen(s) fprintf(s,'*IDN?') idn = fscanf(s); fclose(s) delete(s) clear s
Tips
When you deleteobj
, it becomes aninvalidobject. Because you cannot connect an invalid serial port object to the device, you should remove it from the workspace with theclear
command. If multiple references toobj
exist in the workspace, then deleting one reference invalidates the remaining references.
Ifobj
is connected to the device, it has aStatus
property value ofopen
. If you issuedelete
whileobj
is connected, then the connection is automatically broken. You can also disconnectobj
from the device with thefclose
function.