-
7 Comments
Hah, "Undefined function or variable 'normr'." A while back I had a version with normalizeVector3d(), part of the geom3d() package I use all the time...
I'd be interested to see under the hood of normr... I hope it's vectorized via bsxfun()
no it doesn't! it does something like:
n = sqrt(sum(x.^2,2));
x = x ./ n(:, ones(1, size(x,2)));
Well then, I bet that the following would run faster and work on any dimensioned data (such as a [10,2,50] sized matrix representing 50 sets of 10 XY vectors):
normr = @(v)bsxfun(@rdivide, v, sqrt(sum(v.^2, 2)));
Suggested Problems
-
3894 Solvers
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
1860 Solvers
-
Return the 'Size' of a String of Code
126 Solvers
-
Back to basics 24 - Symbolic variables
143 Solvers
-
840 Solvers
More from this Author5
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!