program that calls itself
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
更多回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!