How to do the mean with a condition?
1 view (last 30 days)
Show older comments
Hello,
Here is my problem, i have a huge matrix. And i have to do the mean for a row but only with a condition, i created a logical vector which contain 1 when i want to include the value and 0 when i don't.
For example
A=
[2 3 4 5 0
6 7 8 9 1
7 5 1 2 1
2 5 6 9 0]
And i want the mean for the second column when the 4th have a value of 1, so mean=6.
Thanks for your help :)
4 Comments
Image Analyst
on 4 Nov 2013
I guess I'll leave it to someone who is still not confused by what you're saying to answer.
See Also
Categories
Find more on Logical 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!