Documentation

delete (serial)

Remove serial port object from memory

Syntax

delete(obj)

Description

delete(obj)removesobjfrom memory, whereobjis a serial port object or an array of serial port objects.

Examples

This example creates the serial port objectson a Windows®platform, connectssto the device, writes and reads text data, disconnectssfrom the device, removessfrom memory usingdelete, and then removessfrom 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 theclearcommand. If multiple references toobjexist in the workspace, then deleting one reference invalidates the remaining references.

Ifobjis connected to the device, it has aStatusproperty value ofopen. If you issuedeletewhileobjis connected, then the connection is automatically broken. You can also disconnectobjfrom the device with thefclosefunction.

Introduced before R2006a

Was this topic helpful?