%% energy.m
% usage: energy(X)
% X is a vector or matrix
% compute the normalized energy of a vector or matrix
% the sum of squares is divided by the size of the signal
% S. Allen Broughton - 31 Oct 2010
function E = energy(X)
Y = X(:); % convert to column vector
E = real(Y'*Y/length(Y));