function number = cutnum(str,n)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% function number = cutnum(str,n)
%
% PURPOSE: Cut the nth token from str.  Convert it to a number. Assume tokens
% are delimited by white space.
% AUTHOR:  Rob McEwen
% DATE:    00/6/21
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
 remainder = str;
 
 for i=1:n
   [token,remainder]=strtok(remainder,' ');
 end
 number = str2num(token);
 if isempty(number)
   disp([' Error(cutnum): Token ',num2str(n),' is not a number.'])
 end
 return;