I am trying to make a table with the outputs of for loop!
Show older comments
format long
close all
clear all
clc
xu=10;
xl=0;
xrpv=0;
er=0;
f=@(x)(5*exp(0.5*x)+10-x^3.5);
for i=1:1:200;
xr=(xl+xu)/2;
fxr=f(xr);
er=((xr-xrpv)/xr)*100;
xrpv=xr;
if (f(xl)*f(xr)>0)
xl=xr;
else
xu=xr;
end
if abs(er)<10^-6
disp(abs(er));
break
end
end
table like;
i xl xr xu fxr er
1 0 5 10 -208.596 100
2 ** *** * *** ** **
3 ** *** ** ** ** **
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!