Info
This question is closed. Reopen it to edit or answer.
calling a function from.m file A - the function is in .m file B
1 view (last 30 days)
Show older comments
I have a function Fn_A defined in a .m file (say file1.m)
I have another function FN_B defined in a .m file (say file2.m)
I want to call Fn_B from Fn_A. Is it possible?
1 Comment
Answers (1)
Walter Roberson
on 27 Jul 2015
In order to easily call a function from another file, the function must the the first in the second file and the file must be named for the function. In such a case you just call the function normally.
If the function is not the first one in the second file, then in order for the first file to be able to invoke the function, it first needs to have a function handle to the second function. There is no way to generate that handle from outside the second file: you would have to have the first function in that second file construct the handle and make it available to the first function (such as by returning it, or by saving it in a known location such as by using the handles structure)
It is time for you to think about splitting apart that second file.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!