Interpolating evenly spaced 2d matrix from 3 arrays
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
0 comentarios
Respuestas (2)
Walter Roberson
el 20 de En. de 2017
together with ndgrid() or meshgrid(), and invoke the interpolant on the grid.
0 comentarios
John D'Errico
el 20 de En. de 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).
0 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!