Rank deficient warning when performing secant method

2 Ansichten (letzte 30 Tage)
Mhamed Abdlla
Mhamed Abdlla am 24 Apr. 2020
Kommentiert: Pravin Jagtap am 27 Apr. 2020
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 Kommentar
Pravin Jagtap
Pravin Jagtap am 27 Apr. 2020
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by