x = -2;
Tol = 0.0000001;
count = 0;
dx=1;
f=-13;
fprintf('step x dx f(x)\n')
fprintf('---- ----------- --------- ----------\n')
fprintf('%3i %12.8f %12.8f %12.8f\n',count,x,dx,f)
xVec=x;fVec=f;
while (dx > Tol || abs(f)>Tol)
count = count + 1;
fprime = cosx-x;
xnew = x - (f/fprime);
dx=abs(x-xnew);
x = xnew;
f = cosx-x;
fprintf('%3i %12.8f %12.8f %12.8f\n',count,x,dx,f)
end
this is what i was have. how can i fix this?

답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 19일

0 개 추천

You could define cox and cost

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2017년 2월 19일

편집:

2017년 2월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by