有没有办法从关联矩阵绘制图表。 通过图表我的意思是http://en.wikipedia.org/wiki/Graph_(mathematics ) 不是情节。
到目前为止,我只找到了如何将关联矩阵转换为邻接矩阵。
在 R 中,这可以通过 igraph
库实现。那么有没有一种简单的方法可以在matlab中做到这一点
最佳答案
你可以使用gplot
:
k = 1:30;
[B,XY] = bucky;
gplot(B(k,k),XY(k,:),'-*')
axis square
此函数常用于机器学习问题。在搜索时我看到了 implementation for weighted graph plotting .
http://www.mathworks.com/help/matlab/ref/gplot.html
编辑:
dt = 2*pi/10;
t = dt:dt:2*pi;
x = cos(t); y = sin(t);
A = ones(10);
gplot(A,[x' y']);
A = ones(3,3);
gplot(A,[x' y']);
a = [0 1 1; 1 0 0; 1 1 0];
gplot(a,[x' y'] ,'-*');
您所要做的就是确保 XY
平面对于图中的每个节点都有足够的 (x,y) 对。
这是 A 的 gplot
:
关于matlab从关联矩阵绘制图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13309351/