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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!