Mean of values in the 1st column where the value in the second column is zero
1 view (last 30 days)
Show older comments
I have data in a MAT file with 2 columns, the first column is length and the second column is 0 or 1.
eg: Length Y/N
2.5 1
3.2 0
How do I get mean of all values of first column where the value in second column is zero?
0 Comments
Answers (3)
Azzi Abdelmalek
on 28 Feb 2014
Edited: Azzi Abdelmalek
on 28 Feb 2014
M=[2.5 1;3.2 0]
c1=M(:,1)
c2=M(:,2)
idx=c2==0
out=mean(c1(idx))
0 Comments
See Also
Categories
Find more on Data Types 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!