How to filter data from a timetable based on a string value?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juniper Sohn
am 5 Jun. 2019
Kommentiert: Roberto Chang
am 31 Jul. 2021
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 Kommentare
Akzeptierte Antwort
dpb
am 5 Jun. 2019
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 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!