Interpolating evenly spaced 2d matrix from 3 arrays

3 ビュー (過去 30 日間)
Aaron Greenbaum
Aaron Greenbaum 2017 年 1 月 20 日
回答済み: John D'Errico 2017 年 1 月 20 日
I have 3 161x1 arrays that should map to a 161 single points on a matrix, zprime array indicating the x location, yprime the y location, and xprime the depth. None of the values are integers. I then need to create a matrix that interpolates between these points.
I think that meshgrid might be the way to do it, but I'm having a trouble inputting it to make the matrix I want. Here is an example of how I made my arrays.
for n = 1:size(R,1)
xprime(n)=R(n)*cosd(cdata{6}(n))+cdata{3}(n);
yprime(n)=R(n)*sind(90-cdata{7}(n))*sind(cdata{6}(n))+cdata{4}(n);
zprime(n)=R(n)*sind(90-cdata{7}(n))*cosd(cdata{6}(n))+cdata{5}(n);
% 3dvar(n)={zprime(n),yprime(n),zprime(n)};
end
Any advice would be appreciated!
edit, I realize the interpolate may not be the correct word, once I have the data set, I want to fill in the remaining empty cells in the matrix so the data follows the curve.

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 1 月 20 日
together with ndgrid() or meshgrid(), and invoke the interpolant on the grid.

John D'Errico
John D'Errico 2017 年 1 月 20 日
Assuming this corresponds to a single valued function, thus z(x,y), you can use triscatteredinterp or scatteredinterpolant as Walter suggested. Not that those tools will not extrapolate, so if the corners are missing, this is why, because your data did not extend to the corners of the desired lattice.
You can also use my gridfit to create the surface. Again, the data must correspond to a single valued functional form z(x,y).

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by