How to plot point coordinates with connecting lines in between.

조회 수: 161 (최근 30일)
ivordes greenleaf
ivordes greenleaf 2015년 4월 13일
편집: pfb 2015년 4월 13일
So I have a set of point coordinates with a line connects between them, I am not sure about the command to plot those points.
This is what I have:
x(1) = (-5.3185, -2.302585);
x(2) = (-10.0332, -4.6052);
x(3)= (-14.6496, -6.9078);
x(4)=(-19.2959,-9.2103);
plot(x(1),x(2),x(3),,x(4), '*-')
Thanks for any input!

답변 (2개)

Chad Greene
Chad Greene 2015년 4월 13일
x(1) refers to only the first element in some variable x, and similarly, x(2) refers to only the second element. So you can't assign two values to x(1) as you've tried to do with
x(1) = (-5.3185, -2.302585);
One way to do it is to assign x and y values separately:
x = [-5.3185 -10.0332 -14.6496 -19.2959];
y = [-2.302585 -4.6052 -6.9078 -9.2103];
plot(x,y, '*-')

pfb
pfb 2015년 4월 13일
편집: pfb 2015년 4월 13일
that's not matlab syntax. Reading the documentation of "plot" is a good idea here. Type doc plot (enter)
Anyway, you should build vectors with the abscissae and the ordinates (using square parentheses)
x = [-5.3185 -10.0332 -14.6496 ...];
y = [...];
and then simply
plot(x,y)
or
plot(x,y,'.-')

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by