Calling other function from another m file
이전 댓글 표시
Hi
I am trying to call a function from another .m file.
The primary function which is the same name as the file can be called very easily.
But is it possilbe to call one of the sub function from that same .m file?
Or do i need to place it in its seperate file?
Thanks
채택된 답변
추가 답변 (1개)
Steven Lord
2022년 12월 27일
1 개 추천
Only the main function in a function file is directly callable from outside the file. Local functions can be called indirectly if you have a function handle to the local function. In order to do this the function handle would need to be created inside the main function and returned from it.
댓글 수: 2
Dharmesh Joshi
2022년 12월 27일
@Dharmesh Joshi: See the attached m-file for a simple example of this.
f = main_function
f(4)
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!