I wish to convert a matrix to a vector of structs, such that each column of the matrix is represented by a struct.
The problem with the code
M = struct('a',[1 2 8],'b',[2 1 3])
is that I cannot index into M directly by entering
M(1)
or
M(2)
etc… After forming the vector of structs, I need to be able to delete the i-th row (or the i-th field of every struct in the vector.
For example, suppose I have a vector of structs representing people. The vector is named "people", and it has two structs, "name" and "age". I need to be able to refer to all people over the age of 40 using the following code:
people(people.age>40)
or retrieve the names of all people between the age of 20 and 30 using the following code:
people(people.age>=20 & people.age<=30).name
I would greatly appreciate any help.
Best Answer