Calling other function from another m file
12 views (last 30 days)
Show older comments
Dharmesh Joshi on 27 Dec 2022
Commented: Voss on 28 Dec 2022
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?
Edited: the cyclist on 27 Dec 2022
External functions are actually known to MATLAB by their filename, so you do need to put it in a separate file.
@Dharmesh Joshi, check out this documentation about function precedence, for a full answer to your question.
More Answers (1)
Steven Lord on 27 Dec 2022
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.
Voss on 28 Dec 2022
Find more on Files and Folders in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!