Filter löschen
Filter löschen

find if a column vector contains at least element 1

2 Ansichten (letzte 30 Tage)
Salvatore Mazzarino
Salvatore Mazzarino am 20 Sep. 2012
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 Kommentare
Salvatore Mazzarino
Salvatore Mazzarino am 20 Sep. 2012
No I mean check if in the matrix there is at least 1 as a number.
Daniel Shub
Daniel Shub am 20 Sep. 2012
Bearbeitet: Daniel Shub am 20 Sep. 2012
So do you mean any? It would help if you gave a couple of example vectors and what you expect.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 20 Sep. 2012
tf = any(A(:)==1)

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 20 Sep. 2012
Bearbeitet: Azzi Abdelmalek am 20 Sep. 2012
length(a)
Or
numel(a)
  2 Kommentare
Salvatore Mazzarino
Salvatore Mazzarino am 20 Sep. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by