Finding tangent plane with the max range value and z value being equal
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rahal Rodrigo
el 16 de Abr. de 2021
Editada: Andrew Newell
el 16 de Abr. de 2021
Hi there. I'm plotting a tangent plane to a particular surface. However, the range for both x and y if +- sqrt(2), which is +-1.41. The expected value of z for the tangent plane is sqrt(2) as well. However, when i run the command, MATLAB produces an error for that particulat range (produces sucessful output on ranges such as +-2). Would be grateful if someone provided insight what I could do to solve this issue. The code is shown below. Any advice would be greatly apreciated.
0 comentarios
Respuesta aceptada
Andrew Newell
el 16 de Abr. de 2021
Editada: Andrew Newell
el 16 de Abr. de 2021
Notice that j is empty, then try this:
X = -1.41:0.01:1.41;
[~,idx] = min(abs(X-1));
disp(X(idx)-1)
This being floating point, you're not getting exact increments of . You could scale everything so x, y are and then find and . Or you could do it like this:
z = @(x,y) sqrt(4-x.^2-y.^2);
X = -1.41:0.01:1.41;
[x,y] = meshgrid(X);
[fx,fy] = gradient(z(x,y),0.01);
[~,j] = min(abs(X-1));
fx0 = fx(j,j);
fy0 = fy(j,j);
z1 = @(x,y) z(1,1) + fx0*(x-1) + fy0*(y-1);
As a side note, you don't need . You can use j directly as logical indexing.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surfaces, Volumes, and Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!