function [out]=num2str2(inputnum,digits);

%converts a number to a string with a specified total number of digits...
%zero padded in front of significant digits
if isint(inputnum)==0 | isint(digits)==0
    error('input number and number of digits must be integers')
end

if digits>=5
    error('this program is only written to include 4 digits at present')
end

if inputnum>=10^(digits);
    error('number of digits to small for input number')

elseif inputnum>=10^(digits-1);
    out=num2str(inputnum);
    
elseif inputnum>=10^(digits-2);
    out=['0', num2str(inputnum)];
        
elseif inputnum>=10^(digits-3);
    out=['00',num2str(inputnum)];
    
else
    out=['000', num2str(inputnum)];
end


%looks good dho 1/05/07
