TOGGLEFIG
by Brett Shoelson
04 Jan 2008
(Updated 26 Jun 2009)
Finds and activates, or creates, figure with user-specified name.
|
Watch this File
|
| File Information |
| Description |
Finds and activates, or creates, figure with user-specified name.
If no name is provided, creates figure named "untitledn" (where n is incremented to result in a unique name).
SYNTAX:
togglefig('My Figure');
If figure named 'My Figure' exists, it will be activated (brought to the front and shown). Otherwise, it will be created.
h = togglefig('My Figure');
Also returns the handle to the specified or created figure.
togglefig;
Creates and activates new figure named untitled1, untitled2, ...
Note: You can subsequently activate these figures with, for instance, togglefig('untitled1').
OTHER EXAMPLES:
NOTE: This example requires the Image Processing Toolbox
im = imread('cameraman.tif');
for ii = 1:10
thresh = ii/20;
togglefig('Threshold');
imshow(im2bw(im,thresh));
title(sprintf('Threshold = %0.2f',thresh));
pause(1)
end
Motivation:
I've found this to be exceptionally useful in algorith-development
mode, particularly when iterating on cells in the cell-mode editor. (I
use this function in almost every mfile I write these days.) |
| MATLAB release |
MATLAB 7.5 (R2007b)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (7) |
| 04 Jan 2008 |
John D'Errico
|
|
|
| 10 Jan 2008 |
Brett Shoelson
|
|
|
| 10 Jan 2008 |
Brett Shoelson
|
|
|
| 10 Jan 2008 |
John D'Errico
|
|
|
| 17 Oct 2008 |
victor de lafuente
|
|
|
| 23 Jun 2009 |
Danilo Zanatta
|
|
|
| 26 Jun 2009 |
Brett Shoelson
|
|
|
| Updates |
| 10 Jan 2008 |
Minor modification to suppress handle generation if no output is requested. |
| 06 Jan 2009 |
I added a new (optional) input argument that triggers a CLF (clear-figure) command. |
| 26 Jun 2009 |
Fixes a bug when togglefig is called with no input arguments. Thanks to Danilo for pointing it out! |
|
Contact us at files@mathworks.com