Show older comments
Hi I have a 1 x 100 row matrix. I want to calculate in one line what percentage (interms of decimal) are the elements which are the number 1 (matrix is full of 1's, -1's and 0s'.)
Then I would like another one line to give the percentage of -1's.
Accepted Answer
More Answers (1)
Walter Roberson
on 14 Jun 2012
mean(YourArray == 1)
Categories
Find more on Creating and Concatenating Matrices 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!