MATLAB: Hello I have a question with struct()

structsum of the fields

I have a struct array() with multiple fields, one of the fields is timediff and it has a set of values. I want to find the sum of this particular field and store it in a variable. Can someone help me with this?
output(activityNum).timediff = etime(endtime,starttime);
output(activityNum).values = zRPM(startind:endind);
output(activityNum).timestampvalues = timestamp(startind:endind);
output here is my struct.

Best Answer

S = sum([output.timediff]);