Why the 'bisect' in my coding is undefined?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hereby, this is my coding and the question is attached below.
Q=20;
g=9.81;
B=@(y)3+y;
Ac=@(y)3*y+y.^2/2;
func=@(y)(1-Q^2*B(y)./(g*Ac(y).^3));
xu=2.5;
xl=0.5;
es=0.01;
n_iter=10;
%%graphically
x=0.5:0.1:2.5;
plot(x,func(x),'r',x,0.*x,'b--');
%%numerically
[root1, f_1, e_1, n_1] = bisect(func,xl,xu,es,n_iter);
[root_2,f_2,e_2,n_2]=false_position(func,xl,xu,es,n_iter);
fprintf('Bisection method: \n');
fprintf('\t root:%g\n',root_1);
fprintf('\t function value at root:%g\n',f_1);
fprintf('\t approximate relative error:%g\n',e_1);
fprintf('\t number of iterations:%d\n\n',n_1);
fprintf('Bisection method: \n');
fprintf('\t root:%g\n',root_2);
fprintf('\t function value at root:%g\n',f_2);
fprintf('\t approximate relative error:%g\n',e_2);
fprintf('\t number of iterations:%d\n\n',n_2);
5 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!