How do extract rows containting certain strings from a table to make a new table?

19 visualizaciones (últimos 30 días)
I have a large input table that has columns containing letters and numbers. I am looking for a way to scan the table to find which rows contain certain words such as "NaN" or "CORRECT" and sort each of those into their own new table. Any advice is appreciated!

Respuesta aceptada

Jon
Jon el 10 de Feb. de 2020
Suppose you had a table called myTable with a column (variable name) named quality with certain words such as 'NaN' 'CORRECT' etc.
You could find the indices of the rows in the table that had for example the word 'CORRECT' using
idxCorrect = strcmpi(myTable.quality,'correct'); % use strcmpi so it will be case insensitive assuming that is what you want
Now make a new table with just those rows
newTable = myTable(idxCorrect,:)
Note though in general it is better not to start making lots of little tables unless you really need to.
Instead if possible just leave the data in the one big table just use your searching as above to find rows with a certain criteria, as needed. Depends on what you are trying to do though. Maybe makes sense in your situation to form some smaller tables.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by