필터 지우기
필터 지우기

Calling an object method on multiple objects of the same class

조회 수: 1 (최근 30일)
Michael Dzjaparidze
Michael Dzjaparidze 2012년 2월 14일
Is there a nice shortcut for calling an object method (i.e. without using a for loop) on multiple instances of a class at the same time which are collected in a vector?
What I do now:
A = [SomeObject, SomeObject, SomeObject]
for n=1:numel(A)
A(n) = A(n).callSomeMethod();
end
I tried
A = [A.callSomeMethod()];
and
A(:) = A(:).callSomeMethod();
but this gives an error.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by