Single coloumn if columns = 1

3 ビュー (過去 30 日間)
Riccardo Rossi
Riccardo Rossi 2018 年 12 月 4 日
コメント済み: Riccardo Rossi 2018 年 12 月 4 日
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 件のコメント
Stephen23
Stephen23 2018 年 12 月 4 日
any(P,2)
Riccardo Rossi
Riccardo Rossi 2018 年 12 月 4 日
Thank you

サインインしてコメントする。

回答 (2 件)

KSSV
KSSV 2018 年 12 月 4 日
P = round(rand(10,3)) ;
idx = find(any(P,2))
Read about any

madhan ravi
madhan ravi 2018 年 12 月 4 日

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by