Info
此问题已关闭。 请重新打开它进行编辑或回答。
calling a function from.m file A - the function is in .m file B
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2015-7-27
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!