How to extract data from specific row
Mostra commenti meno recenti
Hi,
I am still new using MATLAB. For your information, I have the data at the workspace (40000 x 7 double) but how can I extract the data at the row with the value of the first column is 1 or 2? Thank you in advance.

Risposta accettata
Più risposte (1)
Mathieu NOE
il 3 Gen 2023
If your data is A , the rows that contains 1 in the first column are defined by ind1
see example below
% dummy data
A = rand(10,10);
A(:,1) = randi(3,10,1);
% extract data when first column contain 1
ind1 = (A(:,1)==1); % logical index
A1 = A(ind1,:) % A extract for first column containing 1's
% extract data when first column contain 2
ind2 = (A(:,1)==2); % logical index
A2 = A(ind2,:) % A extract for first column containing 2's
1 Commento
Fouziah Yassin
il 4 Gen 2023
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!