How to input a function in matlab? Trying to find roots for any function using newton

I am trying to figure out how I can input a function , find its derivative and evaluate that derivative at a point. Essentially, program Newton's method.
ex.
function y = newton(function,a,b,Nmax, Tol,x0)
yp = deriv(function)
for i 1:Nmax
x1 = function(x0) - function(x0)/yp(x0)
if x1-x0<tol break; end fprintf('root is %d',x1)
But I am not sure how to use a function as an input or how to use the derivative of that function and apply to x0. I just have the general idea.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2012년 9월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by