Réponse acceptée

Adam Danz
Adam Danz le 19 Nov 2021
Modifié(e) : Adam Danz le 19 Nov 2021
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

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by