採用された回答

Adam Danz
Adam Danz 2021 年 11 月 19 日
編集済み: Adam Danz 2021 年 11 月 19 日

0 投票

Here's how to remove rows or columns that contain only 0s
data = [0 0 0 0; 0 4 5 2; 0 2 5 4; 0 2 4 1]
data = 4×4
0 0 0 0 0 4 5 2 0 2 5 4 0 2 4 1
rowsAll0 = all(data==0,1); % columns of 0s
data(:, rowsAll0) = [];
colsAll0 = all(data==0,2); % rows of 0s
data(colsAll0, :) = []
data = 3×3
4 5 2 2 5 4 2 4 1

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2018b

質問済み:

2021 年 11 月 19 日

編集済み:

2021 年 11 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by