Two ways of M-subfunction definition: what are discrepances?
古いコメントを表示
As known, there are 2 ways -- nested subroutines and secondaries subr.
1. nested
function...
...
function...
...
end
...
end
2. primary/secondary
function
...
end
function
...
end
From header (primary function)one can call both nested and secondary subfunctions.
But what kind is better to use? What are differences between ?
採用された回答
その他の回答 (2 件)
Yoav Livneh
2011 年 5 月 18 日
2 投票
In the first case, the second function is nested and only the outer function can call it. Furthermore the nested function can read and use parameters from the caller function's workspace.
In the second case each function has its own workspace and they don't share parameters.
Igor
2011 年 5 月 18 日
0 投票
2 件のコメント
Andrew Newell
2011 年 5 月 18 日
Yes, subfunctions are a bit like private methods.
No, the value of a function argument is not copied unless the argument is changed within the function. See http://www.mathworks.com/help/techdoc/matlab_prog/brh72ex-2.html#brh72ex-13.
Igor
2011 年 5 月 18 日
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!