slice in 3D

16 views (last 30 days)
Shamsuddeen Abdullahi
Shamsuddeen Abdullahi on 6 Aug 2017
Commented: Walter Roberson on 6 Aug 2017
I want to cut a slice at z=-8.266 (Z is a dependent variable that depends on two independent variables x and y). I typed the equation relating z,x and y. mesh(y,x,z) worked perfectly but when ever I try to have a slice using:
I always get an error message
'V must be a 3-D array'
Some one should pls help.
my code:
z= .......... (an m by n array)
mesh(y,x,z) (works perfeclty)
slice(z,[0:90:360],[100:225:1000],-8.266) (returns V must be a 3-D array).
I want to read all values of x and y at z=-8.266

Accepted Answer

Walter Roberson
Walter Roberson on 6 Aug 2017
In order to use slice, you need three spatial coordinates (x, y, z) and a 3D value array that associates a value with each x, y, z triple.
For your purpose you should probably be using contour3()
contour3(x, y, z, [-8.266, -8.266])
Even if you did have a 3D value array, I suspect you would be wanting isosurface()
Walter Roberson
Walter Roberson on 6 Aug 2017
Chances are high that there are no matrix locations as which z = -8.2660000000000000142108547152020037174224853515625 exactly (the closest double precision value to -8.266 that is representable.) Much more likely is that you have locations at which the value is higher than that on one side and lower on another side.
If you then ask "What are the theoretical coordinates which would give z = -8.2660000000000000142108547152020037174224853515625 ?" then you are probably going to end up with an infinite number of coordinates.
Now, if you use
BW = z >= -8.266;
r = ~BW & imfilter(BW,[1 1 1;1 0 1;1 1 1]);
then r should be true for the pixels that are less than -8.266(etc) but for which there is an adjacent pixel that is greater than that value. Each of those pixels could give rise to at least one (x,y) pair at which one could interpolate the value would be -8.266(etc), if you do a plain linear interpolation between the two positions with the assumption that none of the surrounding pixels influences the result. In this simple model, up to 1/4 of the pixels could give rise to 8 interpolated positions each, or up to 1/2 of the pixels could give rise to 4 interpolated positions each.
I will try to refine my model for 2D linear interpolation, but in the meantime you should be thinking about what results you are after.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!