% Example from lecture slides % Root finding -- incremental search method % % Define the function fx = inline('1.5*x./(1+x.^2).^2 - 0.65*atan(1./x) + 0.65*x./(1+x.^2)','x'); % Initial guesses xstart = 0.000; xstep = 0.100; xstop = 1.000; % for x = xstart:xstep:xstop fprintf('At x = %10.8f, ', x) fprintf('fx(x) = %18.12e\n', fx(x)); end % As a guide, plot the function over a range of x to see % where the intercept the x-axis x1 = [xstart:xstep:xstop]; y1 = fx(x1); xaxis = x1*0.0; plot(x1,y1,x1,xaxis); grid