Include rows containing specific value
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Star Strider
2024 年 8 月 30 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!