separate functions or sub-functions
조회 수: 7 (최근 30일)
이전 댓글 표시
Dear all,
I have a main function and several sub-functions. Usually, I keep the function and the sub-functions in one .m file. alternatively, I also can save each sub-function as a separate .m file, and then invoke them in the main function.
my question is what the difference between this two way. for example, time consuming, memory needs etc...
thank you. George
댓글 수: 0
채택된 답변
Matt J
2013년 6월 10일
Subfunctions cannot be accessed (without a handle) from outside the mfile. So, if you need (convenient) access to them outside the mfile, it is best not to make it a subfunction.
Subfunctions also do get higher precedence on the search path, but I doubt you would ever see a consequential performance difference because of that.
댓글 수: 2
Iain
2013년 6월 12일
If you use NESTED functions, you might notice memory consumption differences.
function func1
function func2
do something
end
func2
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!