Gradient function not matching array dimensions
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Carlos Martinez
am 16 Mär. 2023
Kommentiert: Matt J
am 16 Mär. 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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Matt J
am 16 Mär. 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 Kommentare
Matt J
am 16 Mär. 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
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!