Borrar filtros
Borrar filtros

Find Z-value corresponding to X and Y points

30 visualizaciones (últimos 30 días)
Kyle Chudler
Kyle Chudler el 1 de Jul. de 2015
Comentada: Akbar Raza el 16 de Mzo. de 2017
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!

Respuestas (1)

Mike Garrity
Mike Garrity el 1 de Jul. de 2015
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 comentarios
Akbar Raza
Akbar Raza el 16 de Mzo. de 2017
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 el 16 de Mzo. de 2017
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

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by