21 lines
278 B
Mathematica
21 lines
278 B
Mathematica
|
|
%*** BASIC HELPER FUNCTIONS ***
|
||
|
|
|
||
|
|
function norm_v = Normalize(V)
|
||
|
|
% Takes in a vector.
|
||
|
|
% Scales it to a unit vector.
|
||
|
|
% Example Input:
|
||
|
|
%{
|
||
|
|
clear; clc;
|
||
|
|
V = [1; 2; 3];
|
||
|
|
norm_v = Normalize(V)
|
||
|
|
%}
|
||
|
|
% Output:
|
||
|
|
% norm_v =
|
||
|
|
% 0.2673
|
||
|
|
% 0.5345
|
||
|
|
% 0.8018
|
||
|
|
|
||
|
|
norm_v = V / norm(V);
|
||
|
|
end
|
||
|
|
|