How do I split a cell array of data I imported from Excel?
古いコメントを表示
I imported a table from Excel. I don't know how to split it into two tables. For example:
F0 mean F0 max
P1aaa 0,5 1,2
P1bbb 0,4 1,2
P2ccc 0,3 1,8
P1ddd 0,2 1,3
P2eee 0,3 1,9
RESULT:
1.table 2.table
F0 mean F0 max F0 mean F0 max
P1aaa 0,5 1,2 P2ccc 0,3 1,8
P1bbb 0,4 1,2 P2eee 0,3 1,9
P1ddd 0,2 1,3
1 件のコメント
Todd Flanagan
2011 年 1 月 21 日
Hi Michal, I moved your answer to a comment on Andreas' answer. That is a good place for that sort of back and forth.
回答 (2 件)
Andreas Goser
2011 年 1 月 21 日
That depends on how you import it and what the resulting 'table' should be. A cell array?
[num, txt, raw]=xlsread('pathtofile\Book1.xlsx'); % Example to ead
txt(2:4,1) % access to headers
num(1:3,1:2) % access to data
1 件のコメント
Todd Flanagan
2011 年 1 月 21 日
Michal says, "Yes, I need 2 'tables' as a cell array. Excel imported as well, but I don't know how the split as in the example (RESULT). (P1 to automatically classed in 1.table and P2 to classed in 2.table)"
Walter Roberson
2011 年 1 月 21 日
0 投票
Once you have the first column extracted out of the text array,
TableNums = cellfun(@(L) L(2)=='1' + 2 * L(2)=='2', TheFirstColumn);
Then the rows that should go in Table 1 would be those for which TableNums == 1, and the rows that should go in Table 2 would be those for which TableNums == 2; everything else should have TableNums == 0
If a cell could be empty the code would have to be modified a bit.
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!