t1 = (t0 - (y1/y2)); %Creates a t1 value
while abs(t1-t0) > 1e-6 %Runs a loop when the value is larger than our error
t0 = t1; %New t1 becomes t0
y1 = f(t0); %Defines our functions at new t1
y2 = f(t0);
t1 = (t0 - (y1/y2)); %New t-value, essentially t2 and loops back through.
end
disp(t1)

 채택된 답변

Geoff Hayes
Geoff Hayes 2016년 10월 2일

0 개 추천

EJ - please clarify what you mean by It just will not work correctly. Does the code produce an incorrect answer? Or does the code get stuck in the while loop? Or does it not even enter the loop?
You may also want to look at how y1 and y2* are defined
y1 = f(t0); %Defines our functions at new t1
y2 = f(t0);
They are both initialized to the same value which seems to be incorrect. I suspect that you want
y2 = df(t0);
instead.

추가 답변 (0개)

카테고리

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

질문:

E
E
2016년 10월 1일

편집:

E
E
2016년 10월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by