MATLAB: Can anyone explain what this piece of code do

[u,v] = pol2cart(center(:,3),8);

Best Answer

  • The first line converts a (Nx3) matrix ‘center’ where ‘center(:,3)’ is a vector of angles, apparently defining vectors in those directions with a constant length of 8, and converts it to Cartesian coordinates.
    The second line (using the quiver function) plots arrows with the first two columns of ‘center’ defining the the origins of the arrows and ‘u’ and ‘v’ (calculated in the first line) defining their directions and lengths.
  • Related Question