How to use gplot function given a matrix?

조회 수: 5 (최근 30일)
Sharif
Sharif 2014년 9월 23일
댓글: lily yang 2017년 4월 10일
Hello everybody I want to take the following matrix and have MATLAB draw a network out of the data within the matrix. I'm almost certain I have to use the gplot function to do this, but I have an error. Here is what I have:
ptCoordMx = [ 2.85714 37.14286; 2.85714 11.42857; 17.14286 11.42857; 25.71429 17.14286; 34.28571 22.85714; 25.71429 5.71429; 34.28571 11.42857; 34.28571 0.00000; 42.85714 17.14286; 42.85714 05.71429; 51.42857 11.42857; 65.71429 11.42857; 65.71429 37.14286; ]
Coordinates = 1:1:100 gplot(ptCoordMx,Coordinates) //// I keep getting an error for this line
any ideas?

답변 (1개)

Mischa Kim
Mischa Kim 2014년 9월 23일
Sharif, check out the example below
Cor = [2 2; 1 -1; -3 -3; -1 1];
A = [0 1 0 1;...
1 0 1 1;...
0 1 0 0;...
1 1 0 0];
gplot(A,Cor)
Cor are the coordinates of in this case of four different points. A is the so-called adjacency matrix that defines which points are interconnected (1) and which are not (0). For example the first point [2 2] is connected with the second [1 -1] and the fourth [-1 1]. The third point [-3 -3] is connected to the second point [1 -1] .
  댓글 수: 1
lily yang
lily yang 2017년 4월 10일
thank you so much. I'm new to this and your answer helped me a lot.

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

카테고리

Help CenterFile Exchange에서 Sparse Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by