Include rows containing specific value
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a 1400*9 table (1400 rows and 9 columns) in MATLAB workspace. Each column has a different name. I want to select rows containing specific value. For example, how can I create a new table containig all rows with value of 0.456 in the column named "Biology"? I tried to use following code, but it gave error.
newData=[Data(find(Data.Biology == 0.456, :))]
0 Commenti
Risposta accettata
Star Strider
il 30 Ago 2024
the value you are searching for. 0.456, may not be the exact value.
Example —
Data = array2table(randn(10,9), 'VariableNames',{'A','Biology','C','D','F','G','H','I','J'});
Data{[2 5 9],2} = 0.456 + randn(3,1)*1E-9 % Create Inexact Values
idx = ismembertol(Data.Biology, 0.456, 1E-4)
numidx = find(idx)
NewData = Data(numidx,:)
The ismembertol function returns a logical vector. To get numeric indices, use find with it.
You may need to adjust the tolerance to work with your data, however this approach should work.
.
2 Commenti
Vedere anche
Categorie
Scopri di più su Tables 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!