MATLAB: Compute the mean of a field in a struct

mean struct fields

Hello, I have an array of student structs. One of the fields is age. How can I compute the mean of ages in the array?
E.g. in my array I have
student(1,1).name = 'James';
student(1,1).lastname= 'Bond';
student(1,1).age= 19;
student(1,2).name = 'John';
student(1,2).lastname= 'Little';
student(1,2).age= 24;
As a result I expect the mean of the two ages, 31 (tks Matt Fig!)
Thanks!

Best Answer

The mean of 19 and 24 is not 33.5.
mean([student.age])