How to replace duplicate elements as 0 in column matrix

2 ビュー (過去 30 日間)
SIVAKUMAR V
SIVAKUMAR V 2016 年 3 月 21 日
編集済み: Andrei Bobrov 2016 年 3 月 21 日
I need to replace the repeated elements in column of a matrix as 0's and delete the rows which has all 0's. If my matrix is like this means. Input =
1 0 0 1
0 1 0 1
0 0 1 1
1 1 1 1
My expected output should be like this
Output =
1 0 0 1
0 1 0 0
0 0 1 0
0 0 0 0 ---> this row should be get deleted in this case

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 3 月 21 日
編集済み: Andrei Bobrov 2016 年 3 月 21 日
Output = cumsum(cumsum(Input)) == 1;
Output = Output(any(Output,2),:)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by