Is it possible to call a class method of all objects in a list?
Example:
%my_objects contains a list of instances of the same user matlab class
my_objects(:).my_func(42);
The purpose of this is to filter indexes instead of using “:”
Example:
my_objects(1:10).my_func(42);
or
my_objects(find(...)).my_func(42);
You can do so if you use
arrayfun(),cellfun()orstructfun(), depending on what “list” means.Let’s assume it is an array (matrix), you can do
which iterates over
my_objectsand callsobj.myfunc(42)for each of the contained objects.