For example, I create a class 'student'
classdef student
properties
name
sex
age
end
methods
function obj = student(name,sex,age)
obj.name = name;
obj.sex = sex;
obj.age = age;
end
end
and then create some objects in an array 'school'
school(1)=student(A,'boy',19)
school(2)=student(B,'girl',18)
school(3)=student(C,'boy',20)
school(4)=student(D,'girl',19)
My question is how to find the index of the objects with certain properties in the array 'school'?
For example, if I want to find students with age 19, the result will be index [1,4]
If I want to find students with age 19 and sex 'boy', the result will be index [1]
Further question 1: how to find the row and colume index? The object with sex 'girl' and age 19 lies in row 1 colume 4.
Further question 2: if school is an cell array, how to solve above problems?