function number = newFigNumber(varargin)

if nargin == 0
    startAtNumber = 1;
else
    startAtNumber = varargin{1};
end


number = startAtNumber;
existingFigureNumbers = get(0,'children');
while true
    if ~ismember(number,existingFigureNumbers)
        break
    else
        number = number + 1;
    end
end
