Create and activate figures by name

버전 1.3.0.0 (2.92 KB) 작성자: Brett Shoelson
Finds and activates, or creates, figure with user-specified name.
다운로드 수: 5.3K
업데이트 날짜: 2015/1/8

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

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.)

인용 양식

Brett Shoelson (2024). Create and activate figures by name (https://www.mathworks.com/matlabcentral/fileexchange/18220-create-and-activate-figures-by-name), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2007b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.3.0.0

R2014b ready.

1.2.0.0

Fixes a bug when togglefig is called with no input arguments. Thanks to Danilo for pointing it out!

1.1.0.0

I added a new (optional) input argument that triggers a CLF (clear-figure) command.

1.0.0.0

Minor modification to suppress handle generation if no output is requested.