Rank deficient warning when performing secant method

I am trying to find an a that returns the value from roret(n,a) to 120. this is my code so far. How can I make it stop when I get an a that gives me roret(n,a) = 120?
I get this following error: Error in roret (line 26)
A(n+1,n-1:n+1) = [(k/(2*h)) (-4*k/(2*h)) ((3*k)/(2*h))+a]; %last row in matrix
Even though when I run roret(n,a) seperatly it works fine.
Please help!
format long
n = 200;
a0 = 20;
a1 = 21;
iter = 0;
tol = 1e-90;
d0 = roret(n,a0);
while abs(a0-a1)>tol % Secant method
d1 = roret(n,a1);
a2 = a1 - ((d1*(a1-a0))/(d1-d0));
d0 = d1;
a0 = a1;
a1 = a2;
iter = iter +1;
d2 = roret(n,a0);
if d2 == 120
break
end
end
a = a0

1 件のコメント

Pravin Jagtap
Pravin Jagtap 2020 年 4 月 27 日
Hello Mhamed,
To understand what's going wrong in the user-defined function 'roret', we need access to it. Share the implementation of 'roret' so that we can help.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2020 年 4 月 24 日

コメント済み:

2020 年 4 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by