%
% - File name : nonlin_onevar_3.m (Generated by Hee Jung : fall/1999)
% - Solve a nonlinear equation of one variable
% - Example problem : solve 0.1*e^(x) + sin(x) -5 = x for x.
% - Method 3 : Express equations in homogeneous form (i.e. f(x)=0) and use
% 'fsolve' command
% (available with optimization toolbox on college facilities but
% not with the student edition)
% - Sources of help on the fsolve command can be found in several ways:
% 1) type help fsolve in matlab command window
% 2) type helpdesk in matlab command window -> click on 'optimization toolbox ref.'
% in the web pages -> click the 'fsolve' function
clear % removes all variables from the workspace
% Define function f(x)
f = inline('0.1*exp(x) + sin(x) -5 - x');
% Find x using fsolve
% you type :
x = fsolve(f,5)
% you'll get : x = 4.6699