Borrar filtros
Borrar filtros

find if a column vector contains at least element 1

2 visualizaciones (últimos 30 días)
I have to check if column vector has at least element 1. Does Matlab have such similar function or I have to build it myself?
  3 comentarios
Salvatore Mazzarino
Salvatore Mazzarino el 20 de Sept. de 2012
No I mean check if in the matrix there is at least 1 as a number.
Daniel Shub
Daniel Shub el 20 de Sept. de 2012
Editada: Daniel Shub el 20 de Sept. de 2012
So do you mean any? It would help if you gave a couple of example vectors and what you expect.

Iniciar sesión para comentar.

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 20 de Sept. de 2012
tf = any(A(:)==1)

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 20 de Sept. de 2012
Editada: Azzi Abdelmalek el 20 de Sept. de 2012
length(a)
Or
numel(a)
  2 comentarios
Salvatore Mazzarino
Salvatore Mazzarino el 20 de Sept. de 2012
No I don't mean check if the matrix has at lest one element. I would know if the matrix contains at least 1. For example:
A=[1 0 0]
this contains 1.
B=[0 0 0]
this contains all zeros.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by