フィルターのクリア

Calling Function within a Function

3 ビュー (過去 30 日間)
Joe
Joe 2012 年 11 月 19 日
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 件のコメント
Matt J
Matt J 2012 年 11 月 19 日
編集済み: Matt J 2012 年 11 月 19 日
The GettingStarted section of the documentation should make it pretty clear how to make function calls inside other functions. It's no different than calling any old stock MATLAB command like SIN, COS, or SUM

サインインしてコメントする。

回答 (1 件)

Image Analyst
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.

カテゴリ

Help Center および File ExchangeData Type Identification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by