function AF = agefact(age, D) %AGEFACT(age) Calculates Ijspeert's age factor (AF) given age in years % and doubling age (D). If not specified D is set at the default 70 years, % based on Ijspeert's equations. % switch nargin case {0} age = 0; D = 70; case {1} D = 70; case {2} otherwise error 'Error: please specify only age and doubling age' end if D==0 error 'D cannot be zero' %error checking to avoid dividing by zero end AF = 1 + (age/D)^4; %Ijspeert actual AF equation