function [bestdim1,bestdim2,bestdim3] = findminRMS(dim1vec,dim2vec,dim3vec,RMS)

% Finds the minimum Root Mean Square (RMS) value of the RMS function, and
%   returns the values bestdim1, bestdim2, and bestdim3 that produce this
%   minimum RMS value.  Vectors dim1vec, dim2vec, and dim3vec represent
%   the values of the input parameters along the first, second, and third
%   dimensions of the RMS function that lead to the RMS values at each point
%   in the RMS matrix.

i = find(RMS == min(min(min(RMS))));

[m,n,o] = ind2sub(size(RMS),i);

bestdim1 = dim1vec(m);
bestdim2 = dim2vec(n);
bestdim3 = dim3vec(o);

