vector partial derivative of a two variable function
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello i have the following function which is dependant on two variables.
Is there a way to find the vector of the derivative with respect to x dz/dx(x,y) where x y are the vectors defined in the code?
Thanks.
x=[0:0.1:1];
y=[0:0.1:1];
z=x.^2+y.^2
0 comentarios
Respuestas (1)
Star Strider
el 4 de Oct. de 2022
x=[0:0.1:1];
y=[0:0.1:1].';
z=x.^2+y.^2;
[Dx,Dy] = gradient(z)
figure
surf(x,y,z)
hold on
surf(x,y,Dx)
hold off
grid on
xlabel('X')
ylabel('Y')
text(x(end), y(1), Dx(1,end), ' \leftarrow Dx', 'Color','r')
In order to do this correctly, ‘z’ needs to be a matrix, so I transposed ‘y’ to create it as such.
.
2 comentarios
Torsten
el 4 de Oct. de 2022
Should be
[Dx,Dy] = gradient(z,0.1);
instead of
[Dx,Dy] = gradient(z)
Ver también
Categorías
Más información sobre External Language Interfaces 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!