forked from agiahi/ARHMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrixToGraph2.m
34 lines (31 loc) · 1.15 KB
/
matrixToGraph2.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
function matrixToGraph2(A,width,length,statecolor,b)
% convert a pdc connectivity matrix to a graph
% input: A ..............: pdc matrix
% width ..........: arrow width
% length .........: arrow length
% statecolor .....: vector of colors encoding states
% b ..............: brightness (optional) of colors (HSV system)
if nargin<4, statecolor=1;b=1;end
n = size(A,1);
d=2*pi/n/20;
if (nargin<6)
xL = 2*pi/n * (1:n);
vLp = [cos(xL+d);sin(xL+d)];
vLm = [cos(xL-d);sin(xL-d)];
end
if (nargin<2)
width = 1;
end
if (nargin<3)
length = 15;
end
for i=1:n
for j=1:n
if i<j
magAij=abs(A(i,j));
magAji=abs(A(j,i));
arrow(vLp(:,i),.95*vLm(:,j)+.05*vLp(:,i),7,'Length',length*magAij^.5,'BaseAngle',[],'TipAngle',[],'Width',width*magAij,'EdgeColor',colmapfunction(A(i,j),statecolor,b),'FaceColor',colmapfunction(A(i,j),statecolor,b));
arrow(vLp(:,j),.95*vLm(:,i)+.05*vLp(:,j),7,'Length',length*magAji^.5,'BaseAngle',[],'TipAngle',[],'Width',width*magAji,'EdgeColor',colmapfunction(A(j,i),statecolor,b),'FaceColor',colmapfunction(A(j,i),statecolor,b));
end
end
end