how to form rectangular matrix of x, y, z in (:,:,3) format from circular data

I have data of D(:,:,3) format where x= 5*sin(theta)cos(phi), y=5*sin(theta)sin(phi) and z some data related to this points where theta= 0-pi/2 and phi = 0-2 pi. how can i rearrange the data of z in to [X,Y]=ndgrid(x,y) for x=linspace(-t,t,n) , y=linspace(-t,t,n) format?

5 件のコメント

Guillaume
Guillaume 2015 年 4 月 20 日
Can you clarify what each dimension of D represent (is it D(y, x, z) and what the values of D represent?
Dhelp
Dhelp 2015 年 4 月 21 日
let D is (100, 100, 3) matrix and D(:,:,1) is x , D(:,:,2) is y , D(:,:,3) is z component ...
Guillaume
Guillaume 2015 年 4 月 21 日
That's what I understood initially, but then I don't understand what the first two dimensions of D represent. I would have thought that D would be a P x 3 matrix, with P the numbers of points.
Dhelp
Dhelp 2015 年 4 月 21 日
let phi = 0, theta = 0:pi/100:2*pi, so we have a matrix (1,100) so for each phi until pi/2 , lets say we have (100,100) matrix , and since x, y, z have different formula we have D(100,100, 3) but this data is not sorted in x or y incremental way , so what i need is to make the matrix in an incremental grid format lets say X=[-5:5], Y=[-5 5]
Titus Edelhofer
Titus Edelhofer 2015 年 4 月 21 日
Hi,
please take a look at the answer below: if you have e.g. x=-5:0.5:5, y=-5:0.5:5, then create matrices X, Y with
[X,Y] = meshgrid(x,y);
Use these matrices as points xi, yi when calling griddata.
Titus

回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2015 年 4 月 21 日
Hi,
if I understand correctly you have a set of points which are given on 3D spheres and want to have them on a regular (cartesian) grid. If this is the case, then you are looking for the function
griddata
You construct the grid using meshgrid or ndgrid and use griddata to interpolate your points onto this grid.
Titus

1 件のコメント

Dhelp
Dhelp 2015 年 4 月 22 日
Thank you

この質問は閉じられています。

質問済み:

2015 年 4 月 20 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by