Hi everyone, i have a logical array P 378812x400 logical.
I want to create a single column that has the value of row 1 if in the 400 columns at least 1 row was 1.
I tried with this, but it does not run:
N=400
for j=1:N-1
for i=2:N
Q=or(P(:,j), P (:,i));
end
end
Thank you.

댓글 수: 4

madhan ravi
madhan ravi 2018년 12월 4일
편집: madhan ravi 2018년 12월 4일
just give a small example and your desired result ?
Riccardo Rossi
Riccardo Rossi 2018년 12월 4일
P=
0 0 0 0
0 0 1 0
0 0 0 0
0 1 1 0
I would like to have:
Q=
0
1
0
1
Stephen23
Stephen23 2018년 12월 4일
any(P,2)
Riccardo Rossi
Riccardo Rossi 2018년 12월 4일
Thank you

댓글을 달려면 로그인하십시오.

답변 (2개)

KSSV
KSSV 2018년 12월 4일

0 개 추천

P = round(rand(10,3)) ;
idx = find(any(P,2))
Read about any

카테고리

도움말 센터File Exchange에서 Aerospace Blockset에 대해 자세히 알아보기

태그

질문:

2018년 12월 4일

댓글:

2018년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by