Calculate mean of column in structure if another row = 1
Show older comments
I have a structure that has columns Correct (either 0 or 1) and Latency. I am attempting to calculate a mean of the Latency values ONLY if correct = 1. So the Latency mean value from the data set below I am hoping to get is 402
Correct Latency
1 325
0 359
1 410
1 425
0 371
1 448
I have attempted something like this:
if struct.Correct == 1
latmean = mean(struct.Latency)
end
But I get the error "Error using == Too many input arguments"
Any thoughts on a way to achieve this? Thanks
1 Comment
Daniel
on 13 Sep 2014
Accepted Answer
More Answers (0)
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!