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

19 ビュー (過去 30 日間)
new2matlab
new2matlab 2020 年 2 月 10 日
コメント済み: Stephen23 2020 年 2 月 10 日
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!

採用された回答

Jon
Jon 2020 年 2 月 10 日
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.
  1 件のコメント
Stephen23
Stephen23 2020 年 2 月 10 日
"...in general it is better not to start making lots of little tables unless you really need to."
Indeed, a much better approach is usually like this:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by