-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet_Figure.m
More file actions
60 lines (60 loc) · 1.97 KB
/
Get_Figure.m
File metadata and controls
60 lines (60 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
%% Creates or selects a figure without making it the active window in Windows
%:Inputs:
% - Figure_ID (Handle) ; Handle reference to the figure window
% - Hide_Figure (boolean) ; If the figure should be hidden or not
function Figure_ID = Get_Figure(Figure_ID, Hide_Figure)
%Only figure ID parsed
if(nargin == 1)
%% Check if figure exists
if(isempty(Figure_ID))
%% Figure doesn't exist
%create figure
Figure_ID = figure();
elseif(~ishandle(Figure_ID))
%% Figure doesn't exist
%create figure
Figure_ID = figure();
else
%% Figure exists
%Select figure
set(0, 'CurrentFigure', Figure_ID);
end
%Figure ID and hide argument stated
elseif(nargin == 2)
%% Check if figure exists
if(isempty(Figure_ID))
%% Figure doesn't exist
%create figure
Figure_ID = figure();
%if hiding graphs from user
if(Hide_Figure)
set(Figure_ID,'visible','off');
else
set(Figure_ID,'visible','on');
end
elseif(~ishandle(Figure_ID))
%% Figure doesn't exist
%create figure
Figure_ID = figure();
%if hiding graphs from user
if(Hide_Figure)
set(Figure_ID,'visible','off');
else
set(Figure_ID,'visible','on');
end
else
%% Figure exists
%Select figure
set(0, 'CurrentFigure', Figure_ID);
%if hiding graphs from user
if(Hide_Figure)
set(Figure_ID,'visible','off');
else
set(Figure_ID,'visible','on');
end
end
else
%% No inputs specified; Figure existance can't be verified - create a new figure
Figure_ID = figure();
end
end