MATLAB: Finding an angle for a vector perpendicular (normal) to a surface.

normal vectorsurface

Hey guys, I got a problem for calculating normal vector of a surface. Actually, I need to calculate fluctuation of a surface in the direction of the normal vector. I wrote some codes but I am not sure which one is correct. data are stored in a matrix A=[x,y,z]. For the sake of simplicity we can assume a unit distance for x and y direction(dx=1 and dy=1). I have attached two pictures here. First one presents my 3D surface and second one shows the desired vector(green vector) and angle. If there is any solution, please post it here.
Thank you in advance

Best Answer

If I understand your Question correctly, the surfnorm function will do what you want.