-
Notifications
You must be signed in to change notification settings - Fork 6
/
formation_gui2.m
121 lines (102 loc) · 5.73 KB
/
formation_gui2.m
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
clc; clear all; close all;
%create figure
figure_h = figure;
% Adjaceny Matrix
% Sets original size of network & time delay
dim = 24;
%--------------------------------------------------------------------------
% # of Nodes static text
uicontrol('Style','text',...
'units','normalized',...
'position',[0.86 0.925 0.07 0.06],...
'String','# of Agents');
%--------------------------------------------------------------------------
% # of Graphs text appears when a "switching graph" is chosen from the
%graph list
switch_text_h = uicontrol('Style','text',...
'visible', 'off',...
'units','normalized',...
'position',[0.58 0.87 0.2 0.03],...
'String','# of Switching Graphs');
%--------------------------------------------------------------------------
% Makes handle for tabledata
tabledata = [11.5 2.26 0 0 0; 11.9 0 0 0 0; -11.9 0 0 0 0; 0 11.9 0 1.884 0; 0 -11.9 0 0 0; 11.5 -2.26 0 3.14 0; -11.5 2.26 0 0 0; -11.5 -2.26 0 0 0; 2.26 11.5 0 0 0; 2.26 -11.5 0 0 0; -2.26 11.5 0 0 0; -2.26 -11.5 0 0 0; 10.4 5.7 0 0 0; 10.4 -5.7 0 0 0; -10.4 5.7 0 0 0; -10.4 -5.7 0 0 0; 5.7 10.4 0 0 0; 5.7 -10.4 0 0 0; -5.7 -10.4 0 0 0; -5.7 10.4 0 0 0; 8.7 8.1 0 0 0; 8.7 -8.1 0 0 0; -8.7 8.1 0 0 0; -8.7 -8.1 0 0 0];
tabledata_h = uitable('visible', 'off',...
'data', tabledata);
%--------------------------------------------------------------------------
% Makes handle for break point (for reset button)
break_h = uitable('visible', 'off');
%--------------------------------------------------------------------------
% Makes handle for adjacency matrix, which stores data in a uitable that is
% invisible on the GUI.
A_h = uitable('visible', 'off');
%--------------------------------------------------------------------------
% Makes handle for history matrix. This data can be accessed in the
% workspace.
H_h = uitable('visible', 'off');
%--------------------------------------------------------------------------
% Make editable control for number of switch graphs, which becomes visible
% when a "switching graph" is chosen from the graph list.
switch_h = uicontrol('style', 'edit',...
'visible', 'off',...
'units', 'normalized',...
'position', [0.673 0.815 0.05 0.05]);
%--------------------------------------------------------------------------
% Make data table
table_h = uitable('units', 'normalized',...
'position', [0.66 0.41 0.33 0.38],...
'columnname', {'x', 'y', 'delay'},...
'columnwidth', {50 50 50 50},...
'columneditable', [true, true, true],...
'data', get(tabledata_h,'data'),...
'backgroundcolor', [0.7 0.8 0.9; 0.9 0.9608 0.4]);
%--------------------------------------------------------------------------
% Make editable control for number of switching graphs
offset_h = uicontrol('style', 'checkbox',...
'units', 'normalized',...
'string', 'Allow Offset',...
'position', [0.7 0.9 0.15 0.1],...
'callback', {@offset_input, tabledata_h, table_h});
%--------------------------------------------------------------------------
% Graph generator list
list_h = uicontrol('style', 'listbox',...
'units','normalized',...
'position', [0.79 0.82 0.2 0.08],...
'string', {'Cycle Graph'; 'Path Graph'; 'Switching Graph'; 'Custom'},...
'callback',{@operations, A_h, table_h, switch_h, switch_text_h, offset_h});
%--------------------------------------------------------------------------
% Set network size, passes handle to dim_table.m function to make table
% size as desired.
network_size_h = uicontrol('style', 'edit',...
'units', 'normalized',...
'position', [0.94 0.93 0.05 0.05],...
'string', dim,...
'callback', {@dim_table,table_h,offset_h});
%--------------------------------------------------------------------------
% Plot nodes, passes handle to plotting.m function
plot_h = uicontrol('style', 'pushbutton',...
'string', 'Plot Graph',...
'units', 'normalized',...
'position', [0.79 0.32 0.2 0.08],...
'callback', {@plotting, table_h, A_h, list_h, network_size_h});
%--------------------------------------------------------------------------
% Average nodes in discrete play mode, passes handle to collectiveavg.m fn
avg_h = uicontrol('style', 'pushbutton',...
'string', 'Average',...
'units', 'normalized',...
'position', [0.79 0.24 0.2 0.08],...
'callback', {@collectiveavg, table_h, A_h, H_h, list_h, break_h, switch_h, offset_h, network_size_h});
%--------------------------------------------------------------------------
% Reset button - resets to original tabledata value
reset_h = uicontrol('style', 'pushbutton',...
'string', 'Reset',...
'units', 'normalized',...
'position', [0.79 0.08 0.2 0.08],...
'callback', {@reset_data, table_h, tabledata_h, network_size_h, offset_h});
%--------------------------------------------------------------------------
% Stop button - resets to original tabledata value
stop_h = uicontrol('style', 'pushbutton',...
'string', 'Stop',...
'units', 'normalized',...
'position', [0.79 0.16 0.2 0.08],...
'callback', {@stop, break_h});