%% 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 solve nonlinear equations in MATLAB
%% SUMMARY
% Language : Matlab 2008a; 
% Authors : Sri Harsha Garapati, Daniel Miller, Autar Kaw; 
% Mfile available at
% http://numericalmethods.eng.usf.edu/blog/nonlinear_equation_blog.m; 
% Last Revised : January 17, 2012; 
% Abstract: This program shows how to solve a nonlinear equations.
clc
clear all

%% INTRODUCTION

disp('ABSTRACT')
disp('   This program shows you an how to solve nonlinear equations')

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/nonlinear_equation_blog.m')
disp(' ')
disp('LAST REVISED')
disp('   January 17, 2012')
disp(' ')

%% INPUTS

syms x               
% nonlinear equation to be solved
eqn='3*x^3-15*x^2+47*x=33';  

%% DISPLAYING INPUTS

disp('INPUTS')
fprintf('  The equation to solve is: %s\n\n',char(eqn))
%% THE CODE
% using the solve command
soln=solve(eqn,x);    
% converting the exact answer to decimal format using double
soln=double(soln);
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
disp('  The complete solution to the equation is:')
disp(soln)