Slice on irregular grid

3 次查看(过去 30 天)
I have a 3D set of data and coordinates (X,Y,Z,D), which has been glued together from 2D matrices. X and Y are regular and monotonic, however Z is not. This prevents me from using the slice function - is there a way around this?
P.S. I know that I can create slices along specific grid lines by using e.g surf(X(i,:,:),Y(i,:,:),Z(i,:,:),D(i,:,:)) However, I would like to slice along any plane, as in slice.m
Thanks for the help!

采纳的回答

James Ramm
James Ramm 2011-1-23
Oh, I should think a bit more before asking as I've now answered my own question. It is simply a case of requiring 2 scattered interpolations instead of 1 grid interpolation.
By treating the 3D volume as a series of 2D slices (each 'page' of the matrix is a new 2D slice), we can first interpolate to find the correct xyz co-ordinates. The plane of the slice dictates the values to be interpolated.
E.G I wish to make a slice in the xy plane. Therefore I require all (unique) y-coordinates, and the x-coord of the plane. By gridding these with meshgrid, I can then interpolate Z of each 2D slice by using TriScatteredInterp (on the original x-y-z grids with the NaNs removed). This gives us the meshgrid results, xi and yi, and zi, the interpolated values. Remember at the end to replicate the n*1 xi-yi grids to the number of 2D slices.
Almost there - I now have a slice with the correct XYZ coordinates. The final step is to interpolate the colour data with another call to TriScatteredInterp, this time a 3D interpolation from the original X-Y-Z-D grids.
A quick call to squeeze to reduce the dimensions to 2 and I am left with the xi,yi,zi and di matrices required by surface.
  1 个评论
Philippe Corner
Philippe Corner 2020-2-4
Der James, I'm currently looking for the same problem. Could guide me about how to solve it? I attached my data and I would like to obtain also plots like Slice function

请先登录,再进行评论。

更多回答(0 个)

类别

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