Interpolating evenly spaced 2d matrix from 3 arrays

조회 수: 2 (최근 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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by