Fitting Scattered Data to a Spherical Surface

5 ビュー (過去 30 日間)
Balengi
Balengi 2011 年 3 月 24 日
I have a function parameterized by theta = [0,pi] and phi = [0,2*pi) such that F = f(theta, phi).
To get more specific, I have 84 scattered data points, where each point consists of (theta, phi, F) where F denotes the height in the (theta, phi) direction.
I want to fit these scattered data to a uniform grid. I have tried using griddata and Triscatterinterp; however, I still obtain a sphere, and it seems the height function F is ignored completely. Have I done something wrong below in my code? Any help would be greatly appreciated. Thanks.
% I form my grid here: new_th=linspace(0,pi,g_rows); new_ph=linspace(0,2*pi,g_rows); [grid_ph,grid_th]=meshgrid(new_ph,new_th);
% using griddata -- I know v4 is slow, but speed is not the goal here new_F = griddata(theta, phi, F, grid_ph, grid_th,'v4');
%forming the surface x(:,:,1)= (new_F).*sin(grid_th).*cos(grid_ph); x(:,:,2)= (new_F).*sin(grid_th).*sin(grid_ph); x(:,:,3)= (new_F).*cos(grid_th); surf(x(:,:,1),x(:,:,2),x(:,:,3));
  2 件のコメント
Ashish Uthama
Ashish Uthama 2011 年 3 月 25 日
Formatting your code with the '{} code' button would help make it more readable.
I think you are trying to interpolate spherical data using Cartesian coordinate interpolation. Maybe you could try obtaining your grid points using sph2cart?
Ashish Uthama
Ashish Uthama 2011 年 3 月 25 日
Also, a runnable sample code helps us give it a spin and try some options (You could make up some dummy data to illustrate your question).

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

回答 (2 件)

Ashish Uthama
Ashish Uthama 2011 年 3 月 25 日
Air code: (havent given it much thought, will try to get back to it later). Consider this a hint for now.
%r phi and th are your scattered data
[x y] = sph2cart(th,phi,ones(size(th)));
%spherical coordinate grid:
gth = linspace(0,pi,20);
gphi = linspace(0,2*pi,20)
%Convert to cartesian coordinates
[gx gy] = sph2cart(gth,gphi,ones(size(gth)));
%Obtain r on the grid
gr = griddata(x,y,r,gx,gy)

Balengi
Balengi 2011 年 3 月 26 日
First, thanks for the tips on properly formatting the code.
That being said, I implemented your air code; however, I wasn't able to obtain an accurate looking surface.
If you would like, I can send you the scattered data points through e-mail. It would be easier, than copying and pasting it all here. Thanks.
  1 件のコメント
Ashish Uthama
Ashish Uthama 2011 年 3 月 28 日
You can still edit the existing question.
Try paring down the data, or create dummy data for the sake of this question. You dont need the exact same data, some representative data enough to make readers here understand what needs to be done.

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

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by