2D circular interpolation (theta, phi) angles

13 次查看(过去 30 天)
Hi, I have a 2D matrix Z that is function of theta and phi coordinates Z(theta,phi). I have a regular grid of theta and phi coordinates along with the value of Z. Then, I have some scattered points theta_i and phi_i for which I want to interpolate the value of Z. This I can do it easily by doing:
Z_i = interp2(theta,phi,Z);
However, the sampling of matrix Z is limited. For example, if the theta and phi step is 1 degree (then theta from 0:1:179 and phi 0:1:359), it may happen that a valid scattered point falls at one edge of the sampling. For instance a point (theta_i,phi_i) = (0,359.5) will raise a NaN during interp2 because it does not know how to interpolate. Due to the circular symmetry of (theta, phi) angles in fact Z(0,360) = Z(0,0) so that all information needed for interpolation is there, however how can I make interp2 make aware of this angular symmetry? I realized using 'spline' actually provides a valid number, however I would prefer not to use it. Thanks!

采纳的回答

Bjorn Gustavsson
Bjorn Gustavsson 2021-8-3
Simply concatenate the Z-values for columns and rows corresponding to theta and phi equal 0 and 1 at the end of Z and extend the range of theta and phi to 0:181 and 0:361. (You might also consider extending to negative angles):
Znew = Z([end-1:end,1:end,1:2],[end-1:end,1:end,1:2]);
theta_new = -2:181;
phi_new = -2:361;
The reason to extend beyond 0-360 is that this ensure periodicity even for the different spline-interpolation methods (I think this is a sufficient number of points added even for 'cubic' interpolation).
HTH

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by