如何获取当前正在执行的函数的全限定名?

How to get the fully-qualified name of the currently executing function?

假设我有:

+MyPackage/+MySubPackage2/some_function.m

如何在 some_function.m 执行时从中生成字符串 'MyPackage.MySubPackage2.some_function'

似乎在 package 中的 class 中调用 mfilename('class') 给出了正确的答案,但是普通函数没有等价物...

...或者有吗?感觉好像我遗漏了一些明显的东西...

如果可以导入包含包(比如p1/p2),那么:

function outputArg1 = some_function()
import p1.p2.*
t = @some_function;
func2str(t)
%ans  = 'p1.p2.some_function'
outputArg1 = ...;
end

也可以使用 this answer 中的方法(可能进行一些更改)来自动执行导入过程。