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:

  1. create array indices , compare against 5 yield logical array can use index array grab ones meet criteria.

    item = obj_array([obj_array.index] == 5) 
  2. use findobj locate object in array particular property/value pair (note works if using handle class , not value class)

    item = findobj(obj_array, 'index', 5) 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -