function [frac] = pcrfrac(vl,maxrank)
% PCRFRAC Fractional indicator function using method of Brown and Donahue.
%
%  frac = pcrfrac(vl,maxrank)
%
% Where:
%
%  frac    is the fractional indicator function
%  vl      is the column vector of eigenvalues
%  maxrank is optional limit to the number of factors tested  
%

% Copyright (c) 1989-92 by The MathWorks, Inc.

[i, j] = size(vl);
ii = i;
frac(i,1)=0;

if nargin == 2, i = maxrank; end

for j = 1:i
      frac(j) = vl(j) / sum(vl(j:ii));
end

