coordinates of points on a rectangular grid

3 ビュー (過去 30 日間)
Bran
Bran 2012 年 12 月 11 日
コメント済み: ling li 2018 年 1 月 15 日
Hi there
I would like to find the coordinates for all lattice points on a 33x33x33 rectangular grid. So I want to have an output that gives me the (x,y,z) for each point on the grid. I tried to use meshgrid in the following way;
meshgrid(-1:0.0625:1, -1:0.0625:1, -1:0.0625:1)
however, I am struggling to interpret the output from this command.
any help would be greatly received. Many many thanks Bran

回答 (2 件)

Neil Traft
Neil Traft 2015 年 3 月 10 日
Well this is a pretty old post but I had the same question and I think you were unduly ignored.
What you were looking for is simply:
[x y z] = meshgrid(-1:0.0625:1, -1:0.0625:1, -1:0.0625:1);
coords = [x(:) y(:) z(:)];
This gives you a list where each row corresponds to a single vertex in the grid. This is useful when you want to iterate over each vertex and perform some operation on it. I used this to form a system of equations, one equation per vertex.
  1 件のコメント
ling li
ling li 2018 年 1 月 15 日
Very useful. Thank you!

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


Image Analyst
Image Analyst 2012 年 12 月 11 日
It's a list of all the x, y, and z coordinates. Let's take a different perspective. Let's say you wanted a list of all the x, y, and z coordinates -- what kind of output would you like to see? Chances are that your answer to that question would pretty much match what meshgrid gives you.
  2 件のコメント
Bran
Bran 2012 年 12 月 11 日
ah OK I see, many thanks... any idea how to general basically a cubic lattice and get the coordinates for the points?
Image Analyst
Image Analyst 2012 年 12 月 11 日
If you want just 8 points that are the vertices of a cube, you'll have to construct that yourself. If you want more points in a different order, then again, you'll have to do it yourself.

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

カテゴリ

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