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

5 views (last 30 days)
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];

Accepted Answer

Walter Roberson
Walter Roberson on 19 Feb 2021
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

More Answers (0)

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!