Wednesday, June 5, 2013

Calculate gradient in the polar coordinates

http://www.mathworks.com/support/solutions/en/data/1-9OM5E4/index.html?product=SL&solution=1-9OM5E4

gradient(F) = del(F)/del(r) + 1/r * del(F)/del(theta)

As a workaround, given:
F = matrix of F values varying along r and theta
r = vector of radius values
theta = vector of radian values

the following code can be used to calculate the gradient.
% Take the gradient of F, suppose that the values of r vary along the rows
% (and are constant along the columns) and that the values of theta vary
% along the columns and are constant along the rows.
[ dFr dFt ] = gradient(F,r,theta);
% Modify the results for dFt, as the second term in the polar gradient
% is divided by the value of r
dFt = dFt./(repmat(r(:)',length(theta),1);

No comments:

Post a Comment