and i got a matrix like this
x =
7 1 here i want to draw a line between the blue circle no.1 with the red triangle no.7
1 1 here i want to draw a line between the blue circle no.1 with the red triangle no.1
9 2 here i want to draw a line between the blue circle no.2 with the red triangle no.9
5 2 and so on...
4 3 .
8 3 .
10 4
7 4
6 5
2 5
but i don't know how to do it Thank you! :)

 채택된 답변

Image Analyst
Image Analyst 2016년 3월 28일

0 개 추천

When you plotted the data with plot() or scatter(), you must have had the coordinates. I'll assume they are called xData and yData. And (the poorly named) x is a list of indexes that you want to draw between. So you'd do
hold on;
for row = 1 : size(x, 1)
x1 = xData(x(row, 1));
y1 = yData(x(row, 1));
x2 = xData(x(row, 2));
y2 = yData(x(row, 2));
line([x1, x2], [y1, y2], 'LineWidth', 2, 'Color', 'k');
end

댓글 수: 1

Image Analyst
Image Analyst 2016년 3월 28일
I don't care if it's random. The fact is you still have the coordinates or there is no possible way you could have created that plot. So my code will work. If you think you don't have any data, then tell me how you created that plot.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

N.
2016년 3월 28일

댓글:

2016년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by