clc clear all disp('PURPOSE') disp(' Showing how to use the log and exp commands') disp('EXAMPLES') % Natural logs (command is log) a=4; alog=log(a); % natural log fprintf(' The natural log of %g is %g\n',a,alog) % Logs with a base of 10 (command is log10) b=5; l10b=log10(b); % log base 10 fprintf(' The log (base 10) of %g is %g\n',b,l10b) % exp function (the command is exp) a=2.4; e7=exp(a); % exp raised to the 2.4 fprintf(' e^%g is %g\n',a,e7) % trig functions (angle measurement input in radians) ang =30; %given in degrees angr=ang*(pi/180); %convert to radians sin30=sin(angr); %sine command cos30=cos(angr); %cosine command tan30=tan(angr); %tangent command fprintf(' sin(%g) = %g\n',angr,sin30) fprintf(' cos(%g) = %g\n',angr,cos30) fprintf(' tan(%g) = %g\n',angr,tan30) % inverse trig functions b=0.87; % side measurement 1 invsin=asin(b); % inverse sine fprintf(' The inverse sine of %g is %g\n',b,invsin) c=0.5; % side measurement 2 invcos=acos(c); % inverse cosine fprintf(' The inverse cosine of %g is %g\n',c,invcos)