Vector Defined by Two Points
72 次查看(过去 30 天)
显示 更早的评论
I have two points P1(x1, y1) and P2(x2, y2). These are cartesian coordinates. How to calculate the vector P1P2 in matlab?
0 个评论
回答(2 个)
Matt Fig
2011-6-1
[(x1-x2) (y1-y2)]
1 个评论
Jan
2011-6-1
+1. I'd suggest to insert a comma to separate the elements. A beginner might be surprised by the different results for [1-2], [1 -2], [1 - 2]. And to be exact, I don't know what happens, if a line continuator is inserted: [1 -...<NewLine>2],
[1 -<space>...<NewLine>2], [1 -...<NewLine><space>2] ?!
Therefore I always use a comma as separator such that inserted or deleted spaces do cause ambiguities: [1,-2].
Nitpicking, I know.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!