How to extract rows given multiple ranges
15 vues (au cours des 30 derniers jours)
So i have a dataset and I'm trying to downsize it, I have data sorted and have extracted the row indeces required to downsize the dataset while maintaining an almost equal amount of samples per class.
Here are the the specified rows. The dataset has 500,000 samples, using these rows downsizes it to about 120,000. I just want to know what I can to extract these from the original dataset keeping all the columns.
KSSV le 30 Mai 2022
Modifié(e) : KSSV le 30 Mai 2022
If you have the indices of rows idx, you can just use
iwant = A(idx,:) ; % where A is your matrix and idx are the row indices
to extract the rows from A wih all the columns.
Note: MATLAB indexing start from 1 and indices should be positive integers or logicals.
In your case, the first number: 0:5000 should be 1:5000.
A = magic(10) % dummy data for demo
idx = [1 3 5 7] ; % extrcat these rows from A
iwant = A(idx,:)