How to get multiple class instances in function?
5 次查看(过去 30 天)
显示 更早的评论
I wanna get two object instance at once in my function like this
classdef MyClass
properties
value
end
methods
function tmp=myfunc(obj1, obj2)
tmp=obj1.value+obj2.value
end
end
end
and in console
a=myclass;
b=myclass;
a.myfunc(a,b);
and error occurs.
it says too many arguments
How to get multiple class instance at once?
0 个评论
采纳的回答
Sean de Wolski
2020-4-14
a.myfunc(b)
% or
myfunc(a, b)
When you call a.function it passes a as the first input so right now you're doing the equivalent of myfunc(a,a,b)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Class File Organization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!