Hello Matlabgeeks, I am trying to add the elements of a field of a struct array using the following syntax:
totaldistancecovered = sum([output.distanceininches]);
and the following is the syntax that I applied to create the field in the struct:
output(activityNum).distanceininches = zDistance(startind:endind);
output is my struct and distanceininches is my field. However, when I use the former syntax to add the elements it is throwing an error:
Error using horzcatDimensions of matrices being concatenated are notconsistent.Error in boutmodification1 (line 99) totaldistancecovered = sum([output.distanceininches]);
Kindly help me with a solution to add the elements of that field. Thanks in advance.
Best Answer