Copying rows from one table to another
44 ビュー (過去 30 日間)
古いコメントを表示
David Cynamon
2016 年 10 月 24 日
コメント済み: Alexandra Harkai
2016 年 10 月 24 日
I have a large table of data which I have managed to filter down to the particular entrees I want by deleting unwanted rows. I'd like to be able to create new tables off of this.
For example making a new table consisting off all rows in the original that have the entree X for field y.
I would like to use this with a logical expression such as
rows = table.Name == 'Smith';
vars = {'Gender','Height','Weight'};
newTable = table(rows,vars)
However when do this it informs me that "==" is not defined for cells. What is the correct way to do this?
0 件のコメント
採用された回答
Alexandra Harkai
2016 年 10 月 24 日
strcmp(table.Name, 'Smith')
would do the trick.
3 件のコメント
Alexandra Harkai
2016 年 10 月 24 日
If your table column for a given variable is a cell array, then you need to get the data 'out' of it: http://uk.mathworks.com/help/matlab/cell-arrays.html
So cell2mat would 'Convert cell array to ordinary array of the underlying data type'.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!