how create coordinate array?

조회 수: 48 (최근 30일)
huda nawaf
huda nawaf 2012년 9월 8일
hi,
I found this function to plot the graph of adjacency matrix.
The input is adj matrix and coordinates array, xy. I have adj matrix , but I do not know how create coordinate array.
please can anybody help me in this regarding?
thanks
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2012년 9월 8일
Which is already part of MATLAB: gplot().

댓글을 달려면 로그인하십시오.

답변 (2개)

nanren888
nanren888 2012년 9월 8일
huda nawaf,
Interesting that the Mathworks copyright is still in the code you are using. It is not clear what is added to gplot by the addition.
gplot has an example in doc: try doc gplot
It seems as a graph has no inherent shape, that you must provide the xy points for each node for it. The example in doc shows a Buckyball node layout.
I've never used gplot before. I read the help, read doc gplot, played a few minutes & have this.
x = 1:2;
y = 1:3;
[XX,YY] = meshgrid(x,y);
a = (rand([2*3,2*3])>0.8);
P=[XX(:),YY(:)];
gplot(a,P,'-*');
axis([0,7,0,7]);
a
P
a =
0 0 0 0 0 1
0 0 1 1 0 1
0 0 1 1 0 0
0 0 0 0 0 0
0 0 1 0 0 1
0 0 1 0 1 1
P =
1 1
1 2
1 3
2 1
2 2
2 3
Maybe it will help a little?
  댓글 수: 4
huda nawaf
huda nawaf 2012년 9월 9일
no walter, my erlier question is see the cluster visually. Now, I need see the nodes of adjacancy matrix how connect to each other.
that figure is not relate with the above matrix.
please, inform me how I can send image , then others see it. I think I sent image in previous time but nobody saw it.
thanks

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2012년 9월 9일
If all you have is the adjacency matrix, then even if the weights of the vertices can be interpreted as distances, it is difficult to reconstruct a planar graph. Oh, algebraically it can be done, but it involves solving (N^2)/2 simultaneous non-linear equations, and that gets very time consuming extremely quickly.
So, you might as well just use rand() to generate random x and y coordinates and graph using those.
  댓글 수: 4
huda nawaf
huda nawaf 2012년 9월 13일
thanks walter, please show me how do that with random coordinates
Walter Roberson
Walter Roberson 2012년 9월 13일
xy = rand(NumberOfNodes, 2);
I suspect that likely NumberOfNodes = size(AdjacencyMatrix, 1);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by