Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by