bounding Interpolation of scatter data to boundaries of the data

All of the examples I have seen involing scatterInterpolant use the meshgrid function, which seems to result in interpolating scatter data to a defined cubic volume.
My scattered data is of the shape of a dome, and would like to limit the interpolation to this shape. I want to interpolate this scattered data and display a 3d plot with slices, and use the interpolated output to color the data. I have gotten this to work, but am getting colors in the areas outside of the dome shape where there are no scatter points.
The current idea I have is to find the top surface bounding my data, and then set all outputs of the interpolation above the surface equal to NaN so as to not color them. Is there an easier way to do this? Is there an interpolating function that bounds to the given data, or could I define a mesh grid only for points under the surface of the dome?
Thanks in advance

댓글 수: 5

I think the way is to make the points lying outside to NaN.
It might help if you posted your code and an example image demonstrating the issue of note.
Stephen23
Stephen23 2021년 7월 7일
편집: Stephen23 2021년 7월 7일
"All of the examples I have seen involing scatterInterpolant use the meshgrid function"
They are just examples. There is absolutely no requirement for the interpolated points to lie on any grid, so you can simply define vectors of the points where you want to interpolate at, and provide those to the interpolation function.
Don't want points outside of the dome? Then don't interpolate them.
Ok this makes sense, but I think the problem lies in trying to setup the data for the slice function which takes data in meshgrid format.
Below is what I am trying to do - Is this the right approach. Currently I get an error with ndgrid since x,y,z,c are 10242x1 dimension vectors, and scatteredInterpolant returns the same number of points. Is there a way to interpolate to a reduced number of datapoints?
F = scatteredInterpolant(x,y,z,c);
[X,Y,Z,V] = ndgrid(F.Points(:,1),F.Points(:,2),F.Points(:,3),F.Values)
slice(X,Y,Z,xslice,yslice,zslice)
x,y,z are the dimensions of each point, c is the value assigned - which will determine the points color in the graph
Thanks in advance!
"but I think the problem lies in trying to setup the data for the slice function which takes data in meshgrid format."
That is a very different question to what you asked about.
If SLICE has specific requirements (I have not looked) e.g. it only works on gridded data, then of course that is what you will have to provide it with. As KSSV wrote, you could set values to NaN, which might give the effect you want.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

제품

질문:

2021년 7월 7일

댓글:

2021년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by