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.
更多回答(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!