Interpolating evenly spaced 2d matrix from 3 arrays

1 Ansicht (letzte 30 Tage)
Aaron Greenbaum
Aaron Greenbaum am 20 Jan. 2017
Beantwortet: John D'Errico am 20 Jan. 2017
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.

Antworten (2)

Walter Roberson
Walter Roberson am 20 Jan. 2017
together with ndgrid() or meshgrid(), and invoke the interpolant on the grid.

John D'Errico
John D'Errico am 20 Jan. 2017
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).

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by