Deleting zeros from cell matrix without resizing or reshaping matrix

22 ビュー (過去 30 日間)
ozgur
ozgur 2014 年 12 月 25 日
回答済み: ozgur 2014 年 12 月 25 日
I have a cell matrix like this
[1] [2] [6] [2] [6] [6] [1] [0] [0]
[1] [7] [2] [5] [0] [6] [4] [7] [1]
[3] [2] [0] [2] [6] [7] [4] [7] [3]
and i want to delete zeros without changing the size or shape of the cell matrix
this the result i want
[1] [2] [6] [2] [6] [6] [1] [] []
[1] [7] [2] [5] [] [6] [4] [7] [1]
[3] [2] [] [2] [6] [7] [4] [7] [3]

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 25 日
編集済み: Azzi Abdelmalek 2014 年 12 月 25 日
a={ 1 2 6 2 6 6 1 0 0;1 7 2 5 0 6 4 7 1;3 2 0 2 6 7 4 7 3 }
a(cellfun(@not,a))={[]}

その他の回答 (1 件)

ozgur
ozgur 2014 年 12 月 25 日
thanks a lot :)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by