Code covered by the BSD License  

Highlights from
fig

fig

by

 

31 May 2006 (Updated )

A function to easily create and select figures

fig(str);
function [handle] = fig(str);
%FIG Figures labelled by string name.
% HANDLE = FIG(STR)
%
% FIG(STR) will bring the figure with name STR to the front and make it the
% current figure. If there is no figure with name STR, it will also be
% created. Outputs the numerical figure handle.
%
% Examples:
%   fig('freq response');
%   handle = fig('coherence')
%
% Will Robertson 2004

if nargin < 1
  str = 'newfig';
end

% background_colour  = get(0,'defaultFigureColor');
background_colour  = [1 1 1];

if length(findobj('name',str))
    handle = figure(findobj('name',str));
else
    handle = figure('Name',str,'NumberTitle','off','color',background_colour);
end

Contact us