Clear Filters
Clear Filters

How to display all values of an iteration?

6 views (last 30 days)
hi so this is my code, currently it only displays the root and the number of bisections, but I need it to also display the value of each iteration, I'm not sure how to do this. Any help would be much appreciated!Capture.JPG
  1 Comment
KSSV on 30 Jan 2020
Edited: KSSV on 30 Jan 2020
Attach your code..not an image snippet. Tell us what value you want to store?

Sign in to comment.

Accepted Answer

Ridwan Alam
Ridwan Alam on 30 Jan 2020
Edited: Ridwan Alam on 30 Jan 2020
for i = 1:100
xc = (x1 + x2)/2;
if f(x1)*f(xc)<0
x2 = xc;
x1 = xc;
disp(['x1 = ',num2str(x1),',' ' x2 = ',num2str(x2)])
if abs(f(x1))<1e-6
you can also use fprintf() instead of disp().
hope this helps.

More Answers (0)


Find more on Startup and Shutdown in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!