program that calls itself

16 ビュー (過去 30 日間)
Oluwa KuIse
Oluwa KuIse 2012 年 2 月 20 日
How do I write a function file that calls itself without getting stuck in an infinite loop? I just want the program to call itself once.

採用された回答

Andrew Newell
Andrew Newell 2012 年 2 月 20 日

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 2 月 20 日
Very simple example:
function x = foo(a,b)
if ~exist('b','var'); x = foo(a,0); return; end
x = a + b;
end

カテゴリ

Help Center および File ExchangeAdding custom doc についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by