How to filter data from a timetable based on a string value?

7 visualizaciones (últimos 30 días)
Juniper Sohn
Juniper Sohn el 5 de Jun. de 2019
Comentada: Roberto Chang el 31 de Jul. de 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!

Respuesta aceptada

dpb
dpb el 5 de Jun. de 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.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by