Reputation:
I have a structure that has several fields each containing a vector of numbers that I want to take their average without a for looping each field ,
a.a=[1 2 3 4 5]
a.b=[4 5 6 7 8 9];
a.c=[23 23 3 3 ];
...
how can I vectorize that ?
Upvotes: 2
Views: 61
Reputation: 26069
you can use structfun
for that, for example:
result = structfun(@mean,a)
Upvotes: 4