문제

Let say that I have 1 matrix with numbers (0,1). How can i create new matrix that is the result of a logical operation among the columns?

eg. A =

       0     0     0     1     0
       1     1     1     1     1
       0     1     1     0     0
       0     0     0     0     1
       1     0     0     1     0
       1     1     1     1     1

 If all elements of **rows** are equal to 1 - 1, if not - 0. 

(like AND operation)

Ans=   0
       1
       0
       0
       0
       1

Thanks!

도움이 되었습니까?

해결책

To solve your problem this would work -

all(A,2)

If you were looking to set elements based on the columnwise data in A, you would do this -

all(A,1)

More info on all, must serve you well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top