No BSD License  

Highlights from
delobject

Be the first to rate this file! 1 Download (last 30 days) File Size: 1.7 KB File ID: #16838

delobject

by Almar Klein

 

12 Oct 2007 (Updated 16 Oct 2007)

Similar to DELETE, but more forgiving, and allows deletion of multiple objects.

| Watch this File

File Information
Description

DELETE OBJECT
 
  DELOBJECT( H ) deletes the object with handle h, but is more forgiving
  than DELETE: when h is empty, zero or not valid, no action is taken.
 
  Additionally, DELOBJECT enables deletion of multiple handles at the same
  time:
  - H can be an array of handles; all objects are deleted.
  - H can be a cell array of handles.
  - H can be a struct, in which case each field is assumed a handle.
  - Each element in the cell array and each field in the struct can be an
    array of handles. Note that using cells and structs is slower than a
    numeric array of handles.
 
                Example:
  h = 0;
  hf = figure; hold on;
  axis([-15 15 -15 15]); axis equal;
  for i=1:10;
    x = sin(0:0.1:2*pi);
    y = cos(0:0.1:2*pi);
    delobject(h);
    h.red = plot( x,y+i,'r');
    h.blue = plot( x,y-i,'g');
    pause(0.5);
  end
  delobject(hf);

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
15 Oct 2007 Jos x@y.z

What do you mean by "... will not fail if the handle is invalid", since you explicity coded, e.g., error([mfilename ': input must be NUMERIC or CELL or STRUCT!']);

Why not issue warnings instead?

16 Oct 2007 almar klein

Yes, the description can be better. I changed it, but it seems it takes a day or two (might be because I changed the title to the function name, making it a new submission.)

To answer your question: delobject is more forgiving. It will simply take no action when the handle is empty, zero or not valid. The error message you pointed out happens on improper use of the function (like suplying a function handle as input argument)

Please login to add a comment or rating.
Updates
16 Oct 2007

description was insufficient

Tag Activity for this File
Tag Applied By Date/Time
gui tools Almar Klein 22 Oct 2008 09:31:27
example Almar Klein 22 Oct 2008 09:31:27
delete Almar Klein 22 Oct 2008 09:31:27
object Almar Klein 22 Oct 2008 09:31:27
handle Almar Klein 22 Oct 2008 09:31:27
delete Geoffrey Lewen 15 Jul 2010 11:25:54

Contact us at files@mathworks.com