function m=mode(x);
%MODE - find the most common occuring value;
%function m=mode(x);
%
%x is a row vector;
%m is a scalar.
%



[a,i]=unique(sort(x));

i2=i-[0 i(1:end-1)];
[dummy,j]=max(i2);
m=a(j);

