调用不在Matlab路径上的函数,但不添加该路径 [英] Call a function that is not on the Matlab path WITHOUT ADDING THAT PATH
问题描述
我一直在寻找整个下午,并且没有找到解决方案,通过指定它的路径,而不是将其目录添加到路径中,从而在matlab中调用函数。
问题与是否有可能调用不在MATLAB路径中的函数?,但在我的情况下,我不想调用内置函数,而只是调用一个函数m-file。
我认为句柄可能是一个解决方案(因为显然它们可以引用不在路径上的函数),但我再次发现无法创建句柄没有 所以解决方案可能来自两个角度: 编辑:我刚刚发现了函数 解决方案如注释1 创建调用函数之前的函数句柄由@Rody Oldenhuis'FEX很好地实现:贡献: I have been searching an entire afternoon and have found no solution to call in matlab a function by specifying its path and not adding its directory to the path. This question is quite similar to Is it possible to call a function that is not in the path in MATLAB?, but in my case, I do not want to call a built-in function, but just a normal function as defined in an m-file. I think handles might be a solution (because apparently they can refer to functions not on the path), but I again found no way to create a handle without So the solution might come from two angles: EDIT: I have just discovered the function The solution as noted in the comment 1 to create a function handle before calling the function is nicely implemented by @Rody Oldenhuis' FEX Contribution:
http://www.mathworks.com/matlabcentral/fileexchange/45941-constructor-for-functionhandles 这篇关于调用不在Matlab路径上的函数,但不添加该路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! cd
-ing到目录,在那里创建它,
1)你知道如何在特定目录中为m文件创建一个句柄。
2)你知道一种调用函数不在matlab路径中。
函数(myhandle)
,它实际上允许您会看到句柄所引用的文件路径。但是仍然没有办法通过修改...
http://www.mathworks.com/matlabcentral/fileexchange/45941-constructor-for-functionhandles cd
-ing to the directory, creating it there and the cd
-ing back. Trying to 'explore' what a function handle object is and how to make one with a reference to a specific function not on the path has led me nowhere.
1) You know how to create a handle for an m-file in a specific directory.
2) You know a way to call a function not on the matlab path.functions(myhandle)
which actually lets you see the filepath to which the handle is referring. But still no way to modify it though...