- That == is an exact comparison. You might need to do a comparison with a tolerance.
- Because your XData & YData are not monotone, you might get more than one match. In that case, r & c will be vectors.
Find Z-value corresponding to X and Y points
38 次查看(过去 30 天)
显示 更早的评论
I'm plotting something using pcolor in Matlab. I am using the code pcolor(X,Y,Z), where X and Y are 2-D matrices of equal size to Z.
My question is that, given a value of X and Y, how can I find the value of Z at this point. For example, the value of Z when X = 10.32 and Y = -12.5. I know how to find the location in the the X and Y matrices where these values occur, but I'm not sure how get the Z value from this.
The Z matrix isn't simply an analytical function of X and Y, rather I was just given value of Z and their corresponding X and Y points.
X and Y are NOT monotonically increasing.
The values of X and Y that I want to find Z at will always be present in the original X and Y matrices. For example, I want to find the value of Z corresponding to the X value at X(10,20) and Y value at Y(15,25).
Thanks!
0 个评论
回答(1 个)
Mike Garrity
2015-7-1
If the X & Y are in the input matrices, then you can do the following:
[x,y,z] = peaks;
h = surf(x,y,z);
[r,c] = find((h.XData==2.625) & (h.YData==2.625));
disp(h.ZData(r,c))
A couple of things to watch out for.
7 个评论
Akbar Raza
2017-3-16
Thanks Walter. Now what I need to do is to stack multiple copies of this data in the z-dimension which will result effectively in a 4D plot. Currently, if we assume that the same data is being used multiple times in the z-dimension, then how can I have a volumetric structure such that it becomes a continuous form of scatter3 plot. Need your help with this problem
Akbar Raza
2017-3-16
what I want eventually is stacking all the slices to make the attached volumetric structure. How can I do that? Please ignore the axis in this figure
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!