Add named_figure utility
This commit is contained in:
parent
e1b62145b1
commit
7f93745d2f
|
|
@ -0,0 +1,21 @@
|
|||
% small utility to have persistent figures, indicized by name
|
||||
function handle = named_figure(figure_name)
|
||||
global smart_figure_map__;
|
||||
if ~isequal(class(smart_figure_map__), 'containers.Map')
|
||||
smart_figure_map__ = containers.Map;
|
||||
end
|
||||
|
||||
create = true;
|
||||
if smart_figure_map__.isKey(figure_name)
|
||||
handle = smart_figure_map__(figure_name);
|
||||
% handle possibly deleted figures
|
||||
if isvalid(handle)
|
||||
create = false;
|
||||
end
|
||||
end
|
||||
if create
|
||||
handle = figure('Name', figure_name);
|
||||
smart_figure_map__(figure_name) = handle;
|
||||
end
|
||||
figure(handle);
|
||||
end
|
||||
Loading…
Reference in New Issue