-
Notifications
You must be signed in to change notification settings - Fork 2
/
gvCommandLineTutorial.m
144 lines (102 loc) · 3.46 KB
/
gvCommandLineTutorial.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
%% GIMBL-Vis Matlab Command Line Interface Tutorial
% This is a tutorial explaining the command line interface for GIMBL-Vis (using
% the Matlab command window).
%
% For a tutorial on the easier-to-use graphical interface, see the slides at:
% http://www.earoberts.com/GIMBL-Vis-Docs/slides.html
%% Setup
% Format
format compact
% Check if in gimbl-vis folder
if ~exist(fullfile('.','gvCommandLineTutorial.m'), 'file')
error('Current folder should be the gimbl-vis folder in order to run this code block.')
end
% Add gv toolbox to Matlab path if needed
if ~exist('gv','class')
addpath(genpath(pwd));
end
% Check for MDD toolbox
if ~exist('MDD','class')
error('Download MDD toolbox: https://github.com/davestanley/MultiDimensionalDictionary');
end
%% Basics %%
%% Open GV GUI with empty model
% 3 ways:
% 1) Using constructor followed by method call
gvObj = gv;
gvObj.run();
% 2) Using static/class method
gv.Run; % or `gvObj = gv.Run;`
% 3) using constructor with simultaneous method call
gv().run % or `gvObj = gv().run;`
%% Object Construction
% Here is some sample data. The data has 4 dimensions.
vec = -9:1:10;
[x,y,z] = meshgrid(vec,vec,vec);
sampleData = x.*y.*z;
sampleData2 = x+y+z;
sampleData2 = sampleData2 + 0.5*max(sampleData2(:))*rand(size(sampleData2));
sampleData3 = x.^2+y+z;
sampleData3 = sampleData3 + 0.5*max(sampleData3(:))*rand(size(sampleData3));
sampleData4 = sqrt(abs(x)).*y.*z;
sampleData4 = sampleData4 + 0.5*max(sampleData4(:))*rand(size(sampleData4));
% Combine data
sampleData = cat(4,sampleData,sampleData2);
sampleData = cat(4,sampleData,sampleData3);
sampleData = cat(4,sampleData,sampleData4);
% Here are some names for the dimensions.
axis_names = {'x','y','z','dataType'};
% Here are the names of the possible values for each dimension.
dataTypeAxisVals = cellfunu(@(x) ['dataType' x],mat2cellstr(1:size(sampleData,4)));
axis_vals = {1:20, 1:20, 1:20, dataTypeAxisVals};
% The name of the multidimensional dataset.
hypercubeName = 'sampleDataset';
% Let's import the same data and axis information.
sampleGvArray = gvArray(sampleData, axis_vals, axis_names);
sampleGvArray.meta.defaultHypercubeName = hypercubeName;
% Let's also store the path to some sample data stored on disk.
% gvFilePath = fullfile('.', 'gvSampleFile.mat');
% 4 ways to use the gv constructor method (ie the class name as a function):
% 1) Create empty gv object
gvObj = gv();
gvObj.summary;
clear gvObj
% 2) Call load method on file/dir. If dir, must have only 1 mat file. File can
% store a gv, gvArray, or MDD object.
% gvObj = gv(gvFilePath);
% gvObj.summary;
%
% gvObj = gv(gvFilePath, hypercubeName);
% gvObj.summary;
% 3) Call gvArray constructor on gvArray/MDD data
gvObj = gv(sampleGvArray);
gvObj.summary;
gvObj.printHypercubeList;
clear gvObj
gvObj = gv(hypercubeName, sampleGvArray);
gvObj.printHypercubeList;
clear gvObj
% 4) Call gvArray constructor on cell/numeric array data. Can be linear
% or multidimensional array data.
gvObj = gv(sampleData);
gvObj.summary;
clear gvObj
gvObj = gv(hypercubeName, sampleData);
gvObj.summary;
clear gvObj
gvObj = gv(sampleData, axis_vals, axis_names);
gvObj.summary;
clear gvObj
gvObj = gv(hypercubeName, sampleData, axis_vals, axis_names);
gvObj.summary;
%% Run from file
% 2 ways to run directly from a file:
% gv(gvFilePath).run;
% gv.Run(gvFilePath);
%% Advanced %%
%% Command line control of GUI
% Switch tabs
gvObj.run();
gvObj.view.gui.selectTab(2);
gvObj.view.gui.selectTab('Main');
%% Dynasim Integration %%