How do I remove rows if the sum of its cells equals to a specific value?
Afficher commentaires plus anciens
I have a big matrix with lots of useless rows ( when the sum of the row = -104000 ). How do I remove these rows based on this condition?
I tried this:
v=1:1:NUMBER_OF_ROWS;
if sum(A(v,:)) == -104000;
A(v,:) = [];
end
but it didn't work.
2 commentaires
Jan
le 30 Sep 2017
"Didn't work" is a weak description of the problem. Prefer to explain, what you observe.
Leonardo Rodrigues
le 30 Sep 2017
Réponse acceptée
Plus de réponses (1)
Marco
le 30 Sep 2017
2 votes
Hello Leonardo, you can use the "removerows" function: https://it.mathworks.com/help/nnet/ref/removerows.html
You can see also this link: https://it.mathworks.com/matlabcentral/answers/41762-delete-row-from-matrix
BR Marco
1 commentaire
Jan
le 30 Sep 2017
Note that you need the Neural Network Toolbox for removerows.
Catégories
En savoir plus sur Elementary Math dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!