フィルターのクリア

How to plot point coordinates with connecting lines in between.

80 ビュー (過去 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 Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by