function m = harmmean(x)
%HARMMEAN Harmonic mean.
%   M = HARMMEAN(X) returns the harmonic mean of the data.
%   The harmonic mean is the inverse of the mean of the inverses 
%   of the elements.
%   For matrix X, HARMMEAN(X) returns a row vector containing
%   the harmonic mean of each column of X.

%   Copyright (c) 1993-96 by The MathWorks, Inc.
%   $Revision: 2.3 $  $Date: 1996/02/13 23:13:30 $

[nrow,ncol] = size(x);

% Turn row vectors into column vectors.
if nrow == 1,
    nrow = ncol;
    ncol = 1;
    x = x';
end

% Take the average of the reciprocals of the columns of X.
m = sum(ones(nrow,ncol)./ x) / nrow;

% Take the reciprocal of the above.
m = ones(1,ncol) ./ m;
