function meanX = meanValue(x,w)
% Returns the mean value of a set of values x with weights w.
% Input
%   x : vector of values x_i
%   w : optional vector of weights, with same lenght as x
%       If not present, all weights are assumed equal 
% Output
%   meanX = (sum_i x_i * w_i) / (sum_i w_i)
% Usage
%   meanX = meanValue(x,w)
% Author
%   Jose M Soler. Nov.2010

if ~exist('w') w=ones(size(x)); end
meanX = sum(x.*w) / sum(w);
end
