首页 > 解决方案 > 从 Matlab 上的另一个文件调用子函数(本地函数)

问题描述

我试图弄清楚如何从另一个 .m 文件中正确调用子函数。我搜索了文档,只找到了使用函数句柄的方式(可以在这里看到:https ://www.mathworks.com/help/matlab/matlab_prog/call-local-functions-using-function-handles .html )

问题是我认为我已经设法在不使用函数句柄的情况下找到了一种方法,并且想知道我在做什么以及它是如何工作的:

on main.m file:

function main
%function main...
end

function z = sub_function(x,y)
%function sub_function...
end

on outside.m file:
function call_to_local_function_from_outside
z = main('sub_function', x,y);
end

Appernalty,这是有效的,但我需要知道为什么?

标签: matlab

解决方案


推荐阅读