Friday, July 31, 2009

delete

Delete files or graphics objects

Syntax

  • delete filename
    delete(h)
    delete('filename')

Description

delete filename deletes the named file from the disk. The filename may include an absolute pathname or a pathname relative to the current directory. The filename may also include wildcards, (*).

delete(h) deletes the graphics object with handle h. The function deletes the object without requesting verification even if the object is a window.

delete('filename') is the function form of delete. Use this form when the filename is stored in a string.

    Note MATLAB does not ask for confirmation when you enter the delete command. To avoid accidentally losing files or graphics objects that you need, make sure that you have accurately specified the items you want deleted.

Examples

To delete all files with a .mat extension in the ../mytests/ directory, type

  • delete('../mytests/*.mat')

To delete a directory, use rmdir rather than delete:

  • rmdir mydirectory


delete (COM)

Delete a COM control or server

Syntax

  • delete(h)

Arguments

h
Handle for a COM object previously returned from actxcontrol, actxserver, get, or invoke.

Description

Release all interfaces derived from the specified COM server or control, and then delete the server or control itself. This is different from releasing an interface, which releases and invalidates only that interface.

Examples

Create a Microsoft Calender application. Then create a TitleFont interface and use it to change the appearance of the font of the calendar's title:

  • f = figure('pos',[300 300 500 500]);
    cal = actxcontrol('mscal.calendar', [0 0 500 500], f);

    TFont = get(cal, 'TitleFont')
    TFont =
    Interface.mscal.calendar.TitleFont

    set(TFont, 'Name', 'Viva BoldExtraExtended');
    set(TFont, 'Bold', 0);

When you're finished working with the title font, release the TitleFont interface:

  • release(TFont);

Now create a GridFont interface and use it to modify the size of the calendar's date numerals:

  • GFont = get(cal, 'GridFont')
    GFont =
    Interface.mscal.calendar.GridFont

    set(GFont, 'Size', 16);

When you're done, delete the cal object and the figure window. Deleting the cal object also releases all interfaces to the object (e.g., GFont):

  • delete(cal);
    delete(f);
    clear f;

Note that, although the object and interfaces themselves have been destroyed, the variables assigned to them still reside in the MATLAB workspace until you remove them with clear.

  • whos
    Name Size Bytes Class

    GFont 1x1 0 handle
    TFone 1x1 0 handle
    cal 1x1 0 handle

    Grand total is 3 elements using 0 bytes


delete (serial)

Remove a serial port object from memory

Syntax

  • delete(obj)

Arguments


obj
A serial port object or an array of serial port objects.

Description

delete(obj) removes obj from memory.

Remarks

When you delete obj, it becomes an invalid object. Because you cannot connect an invalid serial port object to the device, you should remove it from the workspace with the clear command. If multiple references to obj exist in the workspace, then deleting one reference invalidates the remaining references.

If obj is connected to the device, it has a Status property value of open. If you issue delete while obj is connected, then the connection is automatically broken. You can also disconnect obj from the device with the fclose function.

If you use the help command to display help for delete, then you need to supply the pathname shown below.

  • help serial/delete

Example

This example creates the serial port object s, connects s to the device, writes and reads text data, disconnects s from the device, removes s from memory using delete, and then removes s from the workspace using clear.

  • s = serial('COM1');
    fopen(s)
    fprintf(s,'*IDN?')
    idn = fscanf(s);
    fclose(s)
    delete(s)
    clear s


delete (timer)

Remove a timer object from memory

Syntax

  • delete(obj)

Description

delete(obj) removes timer object, obj, from memory. If obj is an array of timer objects, delete removes all the objects from memory.

When you delete a timer object, it becomes invalid and cannot be reused. Use the clear command to remove invalid timer objects from the workspace.

If multiple references to a timer object exist in the workspace, deleting the timer object invalidates the remaining references. Use the clear command to remove the remaining references to the object from the workspace.



deleteproperty (COM)

Remove custom property from COM object

Syntax

  • deleteproperty(h, 'propertyname')

Arguments

h
Handle for a COM object previously returned from actxcontrol, actxserver, get, or invoke.

propertyname
A string specifying the name of the custom property to delete.

Description

Delete a property, propertyname, from the custom properties belonging to object or interface, h.

Examples

Create an mwsamp control and add a new property named Position to it. Assign an array value to the property:

  • f = figure('pos', [100 200 200 200]);
    h = actxcontrol('mwsamp.mwsampctrl.2', [0 0 200 200], f);
    get(h)
    Label: 'Label'
    Radius: 20

    addproperty(h, 'Position');
    set(h, 'Position', [200 120]);
    get(h)
    Label: 'Label'
    Radius: 20
    Position: [200 120]

Delete the custom Position property:

  • deleteproperty(h, 'Position');
    get(h)
    Label: 'Label'
    Radius: 20

No comments:

Post a Comment