function rankSensitivities(m, dOdp, N)
%
% function rankSensitivities(m, dOdp, N)
%
% This function makes a ranked list of the sensitivities in dOdp. It ranks
% by decreasing magnitude of sensitivity, and outputs the parameter index,
% parameter name and sensitivity magnitude.
%
% The optional argument N specifies the number of sensitivities to rank.
% When called with this argument, rankSensitivities displays the top N
% highest-ranking sensitivities.
%
% See also:
% sensitivity
% fitParameters

if nargin<3 || isempty(N)
N = m.nP;
end

W = 5; % width of parameter name field; this seems to work well
[val I] = sort(abs(dOdp), 'descend');
fprintf(1, 'Param #\t\tName\t\t\tValue\t\t\tdGdp\n');
fprintf(1, '-------\t\t----\t\t\t-----\t\t\t----\n');
for i = 1:N
fprintf(1, ' %3d\t\t%s\t\t%10.3g\t\t%10.3g\n', I(i), [m.pNames{I(i)} blanks(W-length(m.pNames{I(i)}))], m.p(I(i)), dOdp(I(i)));
end