How to filter data from a timetable based on a string value?
7 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I am trying to filter a timetable by only selecting data that contain a desired string value in the second column.
My timetable has 3 columns in total: dates, assets, scores (but the dates column is not numbered, so I think Matlab perceives the timetable as having 2 non-time/date columns).
There are many types of assets under my "assets" column but I only want to select data that have "fixedinc" as their asset names.
Could you please tell me which code I should use?
I am completely new to matlab and this part has been a bottleneck.
Thank you!
0 件のコメント
採用された回答
dpb
2019 年 6 月 5 日
Probably something like
isfixed=contains(tt.assets,'fixedinc'); % if string or cell string, should locate
tt(isfixed,:) % will display what was selected
Likely the assets data could effectively be a categorical variable--
tt.assets=categorical(tt.assets); % convert to categorical type
isfixed=(tt.assets=='fixedinc'); % the logical index array w/ categorical type
tt above is, of course, the timetable--use whatever you named yours in place.
Above is purely speculative on the assumption of what the timetable variables actually are which you've not given any real informtion on.
1 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!