How to select rows from an array?
Afficher commentaires plus anciens
I have matrix of A
. I need to select the 2nd, 4th and 6th row. How can I write that in MATLAB code?
Réponses (3)
ANANTA BIJOY BHADRA
le 12 Oct 2022
1 vote
1 commentaire
Casey
le 8 Mai 2024
Thank you for posting, this was helpful.
Torsten
le 12 Oct 2022
B = [A(2,:);A(4,:);A(6,:)]
or if you want the rows one by one:
A2 = A(2,:);
A4 = A(4,:);
A6 = A(6,:);
See this page of the doc to learn about array indexing.
Hint: A(__,:) where the blank is a vector of row indicies.
Catégories
En savoir plus sur Matrix Indexing 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!