% Example 12-1: Solving a nonlinear equation % Initial plot for estimate fplot('x*exp(-x)-0.2', [0 8]) grid on pause % Find the solution between 0 and 1, guess 0.3 x1 = fzero('x*exp(-x)-0.2', 0.3) pause % Find the second solution between 2 and 3 % Define an anonymous function F F = @(x) x*exp(-x)-0.2 fzero(F, 2.5) pause % What if there is no solution? fzero('x^2+1', 1)