How to write a range of coordinates (of an area)

5 ビュー (過去 30 日間)
Yuk Wai Kelvin Chow
Yuk Wai Kelvin Chow 2021 年 2 月 19 日
I want to get a range of coordinate (x,y) for further calculation of distance between them and a specific points
For example a floor plan of 50x20, how can i get all the points ?in a form of matrix?
Width=50
Length=20
x=[0:Width]
y=[0:Length];

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 19 日
Width=5;
Length=3;
x = 0:Width;
y = 0:Length;
[X,Y] = ndgrid(x,y);
XY = [X(:), Y(:)];
disp(XY)
0 0 1 0 2 0 3 0 4 0 5 0 0 1 1 1 2 1 3 1 4 1 5 1 0 2 1 2 2 2 3 2 4 2 5 2 0 3 1 3 2 3 3 3 4 3 5 3
  1 件のコメント
Yuk Wai Kelvin Chow
Yuk Wai Kelvin Chow 2021 年 2 月 19 日
thank you very much, i will try that

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by