figbyname_yp

PURPOSE ^

SYNOPSIS ^

function [ifig] = figbyname_yp(figname,flag)

DESCRIPTION ^

 Retrieve the handle h of the figure whos name is figname. If the figure
 does not exist, then it creates a new figure with this name

 INPUT
    - figname: figure name [1,n]
       (default = '')
    - flag [1,1]: 
            0 -> No action
            1 -> a figure is created or cleared if existing
            2 -> a figure is created but not cleared if existing
       (default = 1)

 OUTPUT: 
    - ifig = figure handle

 By Yves Peysson (CEA-DRFC, yves.peysson@cea.fr) and Joan Decker (CEA-DRFC, joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ifig] = figbyname_yp(figname,flag)
0002 %
0003 % Retrieve the handle h of the figure whos name is figname. If the figure
0004 % does not exist, then it creates a new figure with this name
0005 %
0006 % INPUT
0007 %    - figname: figure name [1,n]
0008 %       (default = '')
0009 %    - flag [1,1]:
0010 %            0 -> No action
0011 %            1 -> a figure is created or cleared if existing
0012 %            2 -> a figure is created but not cleared if existing
0013 %       (default = 1)
0014 %
0015 % OUTPUT:
0016 %    - ifig = figure handle
0017 %
0018 % By Yves Peysson (CEA-DRFC, yves.peysson@cea.fr) and Joan Decker (CEA-DRFC, joan.decker@cea.fr)
0019 %
0020 if nargin < 1
0021     figname = '';
0022 end
0023 %
0024 if nargin < 2
0025     flag = 1;
0026 end
0027 %
0028 ifig = 1;
0029 %
0030 while ishghandle(ifig)
0031     if strfind(get(ifig,'Name'),figname),
0032         if flag == 1,
0033             clf(ifig);
0034         end
0035         flag = 0;
0036         break;
0037     else
0038         ifig = ifig + 1;
0039     end
0040 end
0041 %
0042 if flag >= 1,
0043     figure('Name',figname);
0044 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.