%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  

%% TOPIC
% How to use logarthemic and trignometric functions in MATLAB
%% SUMMARY
% Language : Matlab 2008a; 
% Authors : Sri Harsha Garapati, Daniel Miller, Autar Kaw; 
% Mfile available at
% http://numericalmethods.eng.usf.edu/blog/logsandtrig_sec001_blog.m; 
% Last Revised : January 17, 2012; 
% Abstract: This program shows you an how to use logarthemic functions and
% trignometric functions.
clc
clear all

%% INTRODUCTION

disp('ABSTRACT')
disp('   This program shows you an how to use logarthemic functions and')
disp(' trignometric functions and also how to use inverse trignometric')
disp(' functions ')

disp(' ')
disp('AUTHOR')
disp('   Sri Harsha Garapati, Daniel Miller and')
disp('Autar K Kaw of http://autarkaw.wordpress.com')
disp(' ')
disp('MFILE SOURCE')
disp('   http://numericalmethods.eng.usf.edu/blog/logsandtrig_sec001_blog.m')
disp(' ')
disp('LAST REVISED')
disp('   January 17, 2012')
disp(' ')

%% INPUTS

a=4; %Input variable, a
b=5; % Input variable,b
c=2.4; % Input Vatiable,c
ang =30;            %Input variable"ang", representing angle given in degrees
d=0.87;             % side measurement 1
e=0.5;              % side measurement 2
%% DISPLAYING INPUTS

disp('INPUTS')
fprintf('  The input number a is %g \n',a)
fprintf('  The input number b is %g \n',b)
fprintf('  The input number c is %g \n',c)
fprintf('  The input angle is %g \n',ang)
fprintf('  The input number d is %g \n',d)
fprintf('  The input number e is %g \n',e)
%% THE CODE
% Natural log of variable a (command is log)
alog=log(a);    % natural log

% Logs with a base of 10 of variable b (command is log10)
l10b=log10(b);  % log base 10

% exp function (the command is exp)
f=exp(c);      % exp raised to the 2.4

% trig functions (angle measurement input in radians)
angr=ang*(pi/180);  %convert to radians
sin30=sin(angr);    %sine command
cos30=cos(angr);    %cosine command 
tan30=tan(angr);    %tangent command 

% inverse trig functions
invsin=asin(d);     % inverse sine

invcos=acos(e);     % inverse cosine
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
fprintf('  The natural log of %g is %g\n',a,alog)
fprintf('  The log (base 10) of %g is %g\n',b,l10b)
fprintf('  e^%g is %g\n',c,f)
fprintf('  sin(%g) = %g\n',angr,sin30)
fprintf('  cos(%g) = %g\n',angr,cos30)
fprintf('  tan(%g) = %g\n',angr,tan30)
fprintf('  The inverse sine of %g is %g\n',d,invsin)
fprintf('  The inverse cosine of %g is %g\n',e,invcos)