Code covered by the BSD License  

Highlights from
Toolbox diffc

image thumbnail
from Toolbox diffc by Gabriel Peyre
A toolbox to perform differential calculus on a matrix.

compute_vf_polar_dec(vf)
function [theta,r] = compute_vf_polar_dec(vf)

% compute_vf_orientation - compute the polar decomposition of a vector field.
%
%   [theta,r] = compute_vf_orientation(vf)
%
%   We have vf(k1,k2,:) = [cos(theta(k1,k2));sin(theta(k1,k2))]*r(k1,k2)
%   Note that theta lies in [0,2*pi[
%
%   WORKS ONLY FOR 2D VECTOR FIELD
%
%   Copyright (c) 2004 Gabriel Peyr

if size(vf,3)~=2
    error('Works only for 2D vector fields.');
end

[theta,r] = cart2pol(vf(:,:,1),vf(:,:,2));

Contact us at files@mathworks.com