Slice on irregular grid

4 ビュー (過去 30 日間)
James Ramm
James Ramm 2011 年 1 月 22 日
コメント済み: Philippe Corner 2020 年 2 月 4 日
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 Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by