slice in 3D

18 次查看(过去 30 天)
Hi!
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:
slice(z,[0:90:360],[100:225:1000],-8.266)
I always get an error message
'V must be a 3-D array'
Some one should pls help.
my code:
x=0:90:360;
y=100:225:1000
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

采纳的回答

Walter Roberson
Walter Roberson 2017-8-6
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()
  2 个评论
Shamsuddeen Abdullahi
I want to read all values of x and y at z=-8.266
Walter Roberson
Walter Roberson 2017-8-6
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by