フィルターのクリア

Find Z-value corresponding to X and Y points

30 ビュー (過去 30 日間)
Kyle Chudler
Kyle Chudler 2015 年 7 月 1 日
コメント済み: Akbar Raza 2017 年 3 月 16 日
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!

回答 (1 件)

Mike Garrity
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.
  • 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.
  7 件のコメント
Akbar Raza
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
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 ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by