フィルターのクリア

how to generate random points in a line

10 ビュー (過去 30 日間)
imola
imola 2015 年 2 月 4 日
編集済み: imola 2015 年 2 月 17 日
Dear All,
I need to generate points on a line.
can anyone help me please with any suggestion, I found just one and I need at least 10 points.
Thanks for any help.
Regards,
Imola

採用された回答

Udit Gupta
Udit Gupta 2015 年 2 月 4 日
For each line (edge) of the polyhedron you can write it's equation as
(y - y1) = (y1 - y2)(x - x1)/(x1 - x2)
So in case of edge from vertex (0, 2) to (1, 0) you can generate it as -
x = (1 - 0) * rand(n,1) + 0 ; %(x2-x1)*(n random number)+x1
y = (2 - 0)/(0 - 1) * (x - 0) + 2 ; % (y1-y2)/(x1-x2)*(x-x1) + y1
Here 'n' is the number points you need to generate on the edge. You can do it for each pair of adjacent vertices in a loop.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by