-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen_graph.m
More file actions
40 lines (30 loc) · 3.26 KB
/
gen_graph.m
File metadata and controls
40 lines (30 loc) · 3.26 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
function [ ] = gen_graph( matrix , thres)
% Get Matrix Transpose
matrix = matrix';
% Construct Correlation Matrix
cor_mat = corr(matrix);
% Apply Threshold and Construct Weighted/(Unweighted - See threshold.m) Adjacency Matrix
adj_mat = threshold(cor_mat, thres);
% 2D Coordinates
% XData: [219, 346, 118, 202, 283, 364, 446, 138, 234, 329, 425, 78, 177, 283, 384, 486, 44, 138, 234, 330, 426, 519, 117, 199, 283, 364, 448, 135, 218, 283, 345, 428];
% YData: [120, 120, 193, 208, 211, 207, 191, 254, 261, 261, 254, 312, 312, 312, 312, 312, 392, 367, 361, 362, 369, 392, 431. 415, 411, 413, 430, 513, 501, 512, 501, 514];
% ZData: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0]
% 3D Coordinates
% XData = [-2.695405558 2.695405558 -4.459387187 4.459387187 -5.47913021 5.47913021 -5.831241498 5.831241498 -2.738838019 2.738838019 -6.399087198 6.399087198 -7.304625099 7.304625099 -6.034746843 6.034746843 0 0 0 0 -6.518995129 6.518995129 -6.174969392 6.174969392 -3.784983913 3.784983913 0 0 -3.743504949 3.743504949 -6.118458137 6.118458137];
% YData = [8.884820317 8.884820317 6.021159964 6.021159964 0.284948655 0.284948655 -4.494821698 -4.494821698 -8.607966849 -8.607966849 4.127248875 4.127248875 -1.866238006 -1.866238006 -5.755782196 -5.755782196 7.96264703 9.271139705 -6.676694032 -8.996686498 2.417299399 2.417299399 -2.458138877 -2.458138877 -6.401014415 -6.401014415 9.087440894 3.806770224 6.649204911 6.649204911 4.523870113 4.523870113];
% ZData = [1.088308144 1.088308144 4.365321482 4.365321482 6.38332782 6.38332782 4.955347697 4.955347697 0.239368223 0.239368223 -0.356852241 -0.356852241 -0.629182006 -0.629182006 0.051843011 0.051843011 5.044718001 -2.211516434 6.465208258 0.487952047 -5.253637073 -5.253637073 -5.637380998 -5.637380998 -5.260040689 -5.260040689 1.333345013 7.891304964 -6.530243068 -6.530243068 -4.409174427 -4.409174427];
% Construct Graph Network
G = graph(adj_mat, 'lower');
% Customize Colormap
colormap([0 1 0
0 0 1
1 0 0
0 0 0]);
% Plot Graph G
p = plot(G, 'EdgeCData', G.Edges.Weight, 'LineWidth', G.Edges.Weight*2);
p.XData = [-2.695405558 2.695405558 -4.459387187 4.459387187 -5.47913021 5.47913021 -5.831241498 5.831241498 -2.738838019 2.738838019 -6.399087198 6.399087198 -7.304625099 7.304625099 -6.034746843 6.034746843 0 0 0 0 -6.518995129 6.518995129 -6.174969392 6.174969392 -3.784983913 3.784983913 0 0 -3.743504949 3.743504949 -6.118458137 6.118458137];
p.YData = [8.884820317 8.884820317 6.021159964 6.021159964 0.284948655 0.284948655 -4.494821698 -4.494821698 -8.607966849 -8.607966849 4.127248875 4.127248875 -1.866238006 -1.866238006 -5.755782196 -5.755782196 7.96264703 9.271139705 -6.676694032 -8.996686498 2.417299399 2.417299399 -2.458138877 -2.458138877 -6.401014415 -6.401014415 9.087440894 3.806770224 6.649204911 6.649204911 4.523870113 4.523870113];
p.ZData = [1.088308144 1.088308144 4.365321482 4.365321482 6.38332782 6.38332782 4.955347697 4.955347697 0.239368223 0.239368223 -0.356852241 -0.356852241 -0.629182006 -0.629182006 0.051843011 0.051843011 5.044718001 -2.211516434 6.465208258 0.487952047 -5.253637073 -5.253637073 -5.637380998 -5.637380998 -5.260040689 -5.260040689 1.333345013 7.891304964 -6.530243068 -6.530243068 -4.409174427 -4.409174427];
% Enable Colorbar
colorbar;
end