griddata for closed surface
古いコメントを表示
I have spherical data [theta, phi, R]: R = f(theta, phi)
I need to interpolate this data. I've used griddata function and got a nice result, but with an issue: it's not interpolated as a closed surface:
it looks like a rumpled orange (as I wanted), but there is no smooth seam line. So the data near edges are not interpolated as needed.
Is there any variants of griddata function for closed manifolds? Or maybe some variants to solve this problem?
UPDATE:
I was advised to use scatteredInterpolant:
% Given data [theta phi rho] - Nx1 vectors
% making XYZ scattered data (Nx1 vectors)
[x,y,z] = sph2cart(theta,phi,1);
F = scatteredInterpolant(x,y,z,rho);
% prepare grid for meshing (we'll mesh xyz data, not theta,phi)
nTheta0 = 100; nPhi0 = 100;
theta0 = linspace(-pi, pi, nTheta0);
phi0 = linspace(-pi/2, pi/2, nPhi0);
[theta0, phi0] = meshgrid(theta0, phi0);
% don't know if there is easier way to make rho0 grid
% but this way works too:
rho0 = zeros(nTheta0, nPhi0);
for i=1:nTheta0
for j=1:nPhi0
% current point x y z taken from theta0, phi0 grids
[x_,y_,z_] = sph2cart(theta0(i,j), phi0(i,j), 1);
% interpolated value of this [x y z] point is new rho value
rho0(i,j) = F(x_,y_,z_);
end
end
% xyz grids for meshing
[vx,vy,vz] = sph2cart(theta0, phi0, rho0);
figure; mesh(vx,vy,vz);
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!