oop - Finding an object with a certain property value in an array of objects in MatLab? -
i have class follows
class car properties index price color end end i created array of these objects , added several cars array. cars have unique index. want find car in array index 5. how can this?
you can 1 of 2 ways:
create array indices , compare against
5yieldlogicalarray can use index array grab ones meet criteria.item = obj_array([obj_array.index] == 5)use
findobjlocate object in array particular property/value pair (note works if usinghandleclass , not value class)item = findobj(obj_array, 'index', 5)
Comments
Post a Comment