operation in matrix in matlab
Show older comments
if i want to know the number of times an condition is fullfilled for a matrix, how can i do so;
a=[3 4 2 5 3 5]; %defining a matrix
% now what should i write if i want to know the number of times, a matrix
% has a value greater than 4.
Accepted Answer
More Answers (1)
"...i want to know the number of times, a matrix has a value greater than 4."
The efficient MATLAB approach:
a = [3,4,2,5,3,5];
nnz(a>4)
Categories
Find more on Operators and Elementary Operations 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!