How to plot point coordinates with connecting lines in between.
170 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(2 个)
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, '*-')
0 个评论
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,'.-')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!