classdef hello < handle
methods
function first(obj)
a=4;
function second(obj)
a
end
end
end
end
我希望能够调用函数“obj.second”。调用类中的嵌套函数
这是我曾尝试:
>> hello_obj=hello;
>> hello_obj.first
>> hello_obj.second
No appropriate method, property, or field second for class hello.
>> hello_obj.first.second
Attempt to reference field of non-structure array.
>> hello_obj.first.hello_obj.second
Attempt to reference field of non-structure array.
谢谢
这是不可能的,你为什么认为你必须这样做? – Daniel
我想利用嵌套函数可以访问父函数的工作空间的事实(我不希望“a”是属性)。 –
当你尝试调用'second'时,'a'不再存在。我认为一个财产将是最好的解决方案,但你可以解释你的理由不使用财产。这可能会导致更好的解决方案。 – Daniel