Determine the Z value of a 3D region for a given set of co-ordinates

1 view (last 30 days)
Hi,
I have a 3D matrix and I want to be able to determine the Z value for a given set of X and Y co-ordinates. The X and Y value that i have in mind is not on the regular grid, so I think i will need interpolation to find the Z value.
Can anyone tell me how this can be done ?
Cheers,

Accepted Answer

Joseph Cheng
Joseph Cheng on 29 Jul 2014
the function interp2() will work. The example in the help/documentation is
[X,Y,V] = peaks(10); [Xq,Yq] = meshgrid(-3:.1:3,-3:.1:3);
Vq = interp2(X,Y,V,Xq,Yq); mesh(Xq,Yq,Vq)
As you can see in the interp2 function it has the original X,Y,Z (or in this case V) and then the user defines the Xq and Yq points that are not on the original grid. the Xq and Yq can be a single XY pair to get the interpolated Z value.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!