MATLAB Answers

0

How to retrieve z value from surf plot given x and y?

Asked by Kyle Gao on 19 Sep 2018
Latest activity Commented on by Kyle Gao on 19 Sep 2018
I got a surface useing:
s= surf(X, Y, Z)
Since the X, Y, and Z are discrete, I want to get the consecutive value of Z. For example, the origin data X and Y are all integers, and I don't the relationship between XY and Z, I want to get the z value where X = 1.87 and Y = 2.9. Is it possible? What should I do?

  0 Comments

Sign in to comment.

1 Answer

Answer by Cedric Wannaz
on 19 Sep 2018
Edited by Cedric Wannaz
on 19 Sep 2018
 Accepted Answer

where Xq and Yq are defined using the values given in your question.

  3 Comments

Thank you so much for your help! But I still need the query grid with a certain spacing value by using interp2. My problem is that I can't have the spacing value (or the grid), it needs to give me the Z value for a random X and Y. Any ideas?
Unless I misunderstand your question, you can just set
Xq = 1.87 ;
Yq = 2.9 ;
and have Zq with
Zq = interp2( X, Y, Z, Xq, Yq ) ;
Yeah! This solved my question perfectly!

Sign in to comment.