필터 지우기
필터 지우기

How to plot random (x,y) coordinates on a plot? if X and Y has different values in array form ?And join all these (X,Y) coordinates to from a connected network graph?

조회 수: 2 (최근 30일)
x =
8.7749
15.3103
3.7375
8.9117
5.5205
13.1020
19.1949
10.1191
y =
7.6312
15.9040
9.7953
12.9263
13.5941
3.2522
6.8077
13.9815
(x(1),y(1))=(8.7749, 7.6312)
(x(2),y(2))=(15.3103, 15.9040).......
(x(8),y(8))=(10.1191,13.9815)
connect (x(1),Y(1)) with (x(i),y(i)) where i is 2,3,...8 similarly others points
  댓글 수: 2
Image Analyst
Image Analyst 2017년 3월 18일
Not sure what you mean. Do you simply want to plot a line from every (x,y) point to every other (x,y) point? Or do you want to form a graph or directed graph object? (Look up graph() in the help).
Sneha Kolapalli
Sneha Kolapalli 2017년 3월 18일
편집: Geoff Hayes 2017년 3월 18일
a connected graph connecting all the (x,y) points formed by above-given diff X and Y values

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

답변 (2개)

Geoff Hayes
Geoff Hayes 2017년 3월 18일
Sneha - you will want to iterate over each pair of coordinates and draw a line between each one. For example, you could do
hConnections = [];
close all;
figure;
hold on;
hNodes = plot(x,y,'ro');
for p=1:size(x,1)-1
for q=p+1:size(x,1)
hConnections = [hConnections ; line([x(p);x(q)], [y(p);y(q)])];
end
end
The hNodes and hConnections are just the handles to the drawn nodes and connections respectively.

Afshin Aghayan
Afshin Aghayan 2019년 10월 8일
you can use this code for displaying any data in the form of [x, y, f(x,y)] or data with coordinate

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by