Deleting a Column from an array?
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Delany MacDonald
le 30 Mar 2016
Modifié(e) : Joseph Cheng
le 30 Mar 2016
I am given a 21 x 345 array. I need to delete JUST column 190. How would I do so and keep all the rest the same so that it is a 21 x 344 array
0 commentaires
Réponse acceptée
Star Strider
le 30 Mar 2016
If ‘M’ is your matrix, just set the entire column to the empty array []:
M(:,190) = [];
0 commentaires
Plus de réponses (1)
Joseph Cheng
le 30 Mar 2016
Modifié(e) : Joseph Cheng
le 30 Mar 2016
you can use the indexing of arrays to delete a column.
A = 1:10; %1x10; counting from 1 to 10;
to delete column 9 (ie number 9)
A(:,9)=[] % which reads all rows of A in column 9 is now empty.
Thats what the : in the first part as indexing goes (rows, columns)
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!