Calling Function within a Function
조회 수: 3 (최근 30일)
이전 댓글 표시
Calling a function inside of a another function.
what I would like to do is take
function x = fgIntersect(f, df, g, dg, x0, tol, maxIter)
and calculate the output x using another function,
function [r,rHist,N,fRoot] = newtonRaph(fHan,dfHan,x0,fTol,iterMax)
replacing fHan with h ( h = @ (x) f(x) - g(x)), and dfHan with dh ( dh = @ (x) df(x) - dg(x)).
so I would have:
function [r,rHist,N,fRoot] = newtonRaph(h,dfh,x0, tol,maxIter)
and the output of this function (newtonRaph), r is equal to the output of the previous function (fgIntersect), x.
댓글 수: 1
답변 (1개)
Image Analyst
2012년 11월 19일
So just calculate fHan by calling h(), and calculate dfHan by calling dh(), in advance of you calling newtonRaph(), then pass them in to newtonRaph(). It's a simple process.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Function Creation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!