How do I split a cell array of data I imported from Excel?
Mostrar comentarios más antiguos
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 comentario
Todd Flanagan
el 21 de En. de 2011
Hi Michal, I moved your answer to a comment on Andreas' answer. That is a good place for that sort of back and forth.
Respuestas (2)
Andreas Goser
el 21 de En. de 2011
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 comentario
Todd Flanagan
el 21 de En. de 2011
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
el 21 de En. de 2011
0 votos
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.
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!