remove rows zeros( condition remove)

1 回表示 (過去 30 日間)
ziad abdul
ziad abdul 2018 年 6 月 27 日
回答済み: Jan 2018 年 6 月 27 日
i have a=
1 2 3 4 5
0 0 0 8 9
4 5 8 5 6
0 0 0 8 6
i need a=
1 2 3 4 5
4 5 8 5 6
i have to delete 2. and 4. rows who have zeros (not all rows zeros)in first three column(condition remove)

回答 (2 件)

Jan
Jan 2018 年 6 月 27 日
A = [1 2 3 4 5; ...
0 0 0 8 9; ...
4 5 8 5 6; ...
0 0 0 8 6] ;
index = any(A(:, 1:3), 2);
B = A(index, :)

KSSV
KSSV 2018 年 6 月 27 日
編集済み: KSSV 2018 年 6 月 27 日
A = [1 2 3 4 5
0 0 0 8 9
4 5 8 5 6
0 0 0 8 6] ;
idx = A==0 ;
A(sum(idx(:,1:3),2)==3,:) = [];

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by