Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to show all the midpoints on my bisection code?

Asked by Matthew

Matthew (view profile)

on 19 Nov 2012

I have a code for finding the bisection, but I need to include 3 things please:

  1. output- Root History a vector containing the sequence of midpoints obtained by the algorithm
  2. output- the absolute value of the function f(x) at r, i.e., fRoot = f(r)
  3. input- max iterations
function [R, E] = myBisection(f, a, b, tol)
m = (a + b)/2;
R = m;
E = abs(f(m));
while E(end) > tol
    if sign(f(a)) == sign(f(m))
        a = m;
    else
        b = m;
    end
m = (a + b)/2;
R = [R, m];
E = [E, abs(f(m))];
end

how do I do this? thanks!!

0 Comments

Matthew

Matthew (view profile)

Tags

Products

No products are associated with this question.

0 Answers

Contact us