i want to display my answer in table format with heading for the numerical method .the following is the code .but it does diaplay in proper table

1 次查看(过去 30 天)
f= inline('x^3-2*x-5','x') a=input('enter the lower value='); b=input('enter the upper value='); fa=feval(f,a);% to evalulate the value of function at a fb=feval(f,b); %n=6
while(fa*fb>0)% while loop will run until and unless the expression is false a=input('enter the lower value='); b=input('enter the upper value='); fa=feval(f,a); fb=feval(f,b); end for i=1:1:50 c=(a+b)/2; fc=feval(f,c); e=0.001; error=abs(b-a); t=[ i a fa b fb c fc e] % disp('i a fa b fb c fc e') % disp[(i,a , fa , b, fb ,c , fc, e)] % fprintf('Table of iteration, a,fa,b,fb,c,fc') % fprintf('i a fa b fb c fc')
if (abs(fc)<0.001)
disp(c);
break;
elseif (abs(b-a)<e)
disp(c);
break;
elseif( fa*fc<0)
b=c;
fb=fc;
else
a=c;
fa=fc;
end
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by