How to get multiple class instances in function?
조회 수: 3 (최근 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!