% short matlab script to demonstrate the use of norms

close all
clear all

% set up a vector
x = -(1:4)/5 

% find its 1-norm
norm1 = norm(x,1)

% find its 2-norm (Euclidean norm)
norm2 = norm(x,2)

% the 2-norm happens to be the default
normDef2 = norm(x)

% finally, the infinity (or maximum) norm
normInf = norm(x,Inf)

% what's wrong with max?
notMaxNorm = max(x)

% ... that's better
[anotherNormInf, indexOfMaxComponent] = max(abs(x))
% with this notation you can also find out which component was the max ...