Gradient function not matching array dimensions
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Carlos Martinez
el 16 de Mzo. de 2023
Comentada: Matt J
el 16 de Mzo. de 2023
I have the function
psi=y+atan2(y,x)*0.5/pi;
which is classified as a 51x51 double for its value. How would I take the gradient of x and y for this function?
0 comentarios
Respuesta aceptada
Matt J
el 16 de Mzo. de 2023
psi =rand(51);
[gradx,grady]=gradient(psi);
whos psi gradx grady
0 comentarios
Más respuestas (1)
Matt J
el 16 de Mzo. de 2023
The expression for the gradient is very simple. Why not just apply the analytical expression on whatever meshgrid you are working with?
syms x y real
syms psi
psi=y+atan2(y,x)/2/pi;
g=simplify(gradient(psi))
2 comentarios
Matt J
el 16 de Mzo. de 2023
Perhaps as follows?
function [Gx,Gy]=mygrad(X,Y)
den=2*pi*(X.^2+Y.^2);
Gx=-Y./den;
Gy=X./den+1;
end
Ver también
Categorías
Más información sobre Linear Algebra 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!
