Effacer les filtres
Effacer les filtres

Calling an object method on multiple objects of the same class

1 vue (au cours des 30 derniers jours)
Michael Dzjaparidze
Michael Dzjaparidze le 14 Fév 2012
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.

Réponses (0)

Catégories

En savoir plus sur Construct and Work with Object Arrays dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by