or operation on the columns of a matrix ?

23 Ansichten (letzte 30 Tage)
Nora Khaled
Nora Khaled am 12 Mai 2019
Kommentiert: Nora Khaled am 15 Sep. 2020
Hello!
I have matrix S that contains zeros and ones. and I want to convert it to a column vector contianing one in the ith position if there was at least one one in the ith row.
So I know that "or" operation does similar job but with two vectors. is there a way to use it with the columns of S ?

Akzeptierte Antwort

Image Analyst
Image Analyst am 12 Mai 2019
Try
rowHasOnes = any(S, 2);
If not, then supply an example S and the expected result.
  3 Kommentare
Sanchari Thakur
Sanchari Thakur am 15 Sep. 2020
what is the 'and' version of the 'any' function?
Nora Khaled
Nora Khaled am 15 Sep. 2020
all(A) or all(A, dim)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by