How to compare each element of matrix to specific number and count it ?

1 visualización (últimos 30 días)
I have 3x3 matrix and i want to write code to count the elements which are less than 3 by using if statement .

Respuesta aceptada

Adam Danz
Adam Danz el 13 de Sept. de 2020
Editada: Adam Danz el 13 de Sept. de 2020
m is your matrix, n is the number of values less than 3.
n = sum(m<3,'all')
There's no need for an if-statement.

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by