secant method exceeds the number of array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hi, i'm trying to solve this question but i don't know why i'm getting error every time i run it
here is the qustion part c![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142920/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142920/image.png)
clear
clc
fun=@(x) x^3-6*x^2+11*x-6.1;
x=3.5;
c_factor=0.001;
d=@(x) 3*x^2-12*x+11;
for i=1:100
x(i+2)=x(i)-(fun(x(i))*((x(i+1)-x(i))/(fun(x(i+1))-fun(x(i)))));
e(i)=abs((x(i+1)-x(i))/x(i));
if e(i)<c_factor
break
end
end
fprintf('The root of given equation is: %.4f\n', x(i))
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!