How to apply OR operation to a matrix?

조회 수: 2 (최근 30일)
pietro
pietro 2014년 7월 12일
답변: Roger Stafford 2014년 7월 12일
Hi folk,
I need to apply the OR operation to the column of a matrix. Here an example:
a=[0 0 1; 0 1 1];
orMat(a)=
[0 0 1]
thanks

채택된 답변

Roger Stafford
Roger Stafford 2014년 7월 12일
Your example is not the 'OR', it is the 'AND', of the columns. The 'OR' of the columns is done this way:
b = any(a,1);
The 'AND' would be done this way:
b = all(a,1);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by