%% 1-Norm and 2-Norm of Vector
% Calculate the 2-norm of a vector corresponding to the point (2,2,2) in 3-D space. The 2-norm is equal to the Euclidean length of the vector, \sqrt{12}.

x = [2 2 2];
n = vecnorm(x)

%
% Calculate the 1-norm of the vector, which is the sum of the element magnitudes.

n = vecnorm(x,1)

% Copyright 2012 The MathWorks, Inc.