필터 지우기
필터 지우기

Plotting points and lines

조회 수: 1 (최근 30일)
Manoj
Manoj 2014년 11월 20일
댓글: Manoj 2014년 11월 21일
Hello
I would like to plot these edges and figures as shown in these images. I am able to do it manually using gplot using the following lines code for each one of the figure. But it is time consuming and lot of manual work since I have a lot of these figures to plot (over 50).
G = [0,0,0,0,0; 0,0,1,0,0; 0,0,0,0,1; 0,0,0,0,0; 0,0,0,0,0];
xy = [ 5 10; 0 5; 5 1 ; 10 7.5; 10 2.5];
gplot(G,xy,'-o');
axis([0 75 0 75]) % To Center the Figure
Is there any better way to do this or would you recommend any other tool or software.
Also as you can see, there are two lines between two points. like in the nodes_required jpeg figure, but unfortunately I cannot do this in matlab as well. Is there a way to do this or another possibility could be to use different colours for two lines , three lines and so on.
Thanks in advance
  댓글 수: 3
Guillaume
Guillaume 2014년 11월 21일
Does your data come as an adjacency matrix? If so, how do you decide which edges have a double line? If not, how is it represented?
Manoj
Manoj 2014년 11월 21일
편집: Manoj 2014년 11월 21일
I have representations of the form for Eg:
m=[ 2 4 1 5 0
1 5 0 0 0];
% 12 13 14 15 23 24 25 34 35 45
n=[0 0 1 2 0 2 0 0 0 0
0 0 0 1 0 0 0 0 0 0];
AS you can see the numbers in the n matrix determines if it needs to have a double line. In the first row , 15 and 24 have a double line.
I have written a code which gets the adjacency matrix from m and n of the form for row 1
adj_matrix=[0 0 0 1 2
0 0 0 2 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0]
So where ever you see a 2,3.. in the adjacency matrix , I need a double line or a different colored line

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

채택된 답변

Thorsten
Thorsten 2014년 11월 21일
편집: Thorsten 2014년 11월 21일
This should give you an idea how to solve it
gplot(adj_matrix==1, m', 'bo-')
gplot(adj_matrix==2, m', 'ro-')
gplot(adj_matrix==3, m', 'ko-')
  댓글 수: 1
Manoj
Manoj 2014년 11월 21일
Thank you for your answer, I got an idea how to solve it. I will get back to you if it works or not.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by