Could anyone help me how to extract different specific number of rows in a matrix.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am a matrix of size A= rand(100,1)
I want to generate matrix by extracting 2 rows in interval of 5.
B=A([1:2,6:7,11:12,16:17,........,96:97],:).
Could anyone help me to write in the simplified form to execute in matlab.
0 Commenti
Risposte (2)
Walter Roberson
il 25 Giu 2021
row_idx = reshape((1:5:100) + [0;1],1,[])
3 Commenti
Walter Roberson
il 25 Giu 2021
?? row_idx is already a separate matrix. You take it and
B = A(row_idx,:);
Walter Roberson
il 25 Giu 2021
For 2, 3, 4 of each group of 5,
row_idx = reshape((1:5:100) + [1;2;3],1,[])
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!