Create a subtable from a larger table
145 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Wendy Cameron
el 20 de Jun. de 2018
Comentada: Peter Perkins
el 3 de Jul. de 2018
Hi Everyone, I'm hoping this specific question might be useful too in other more general situations.
I have some sample data attached and want to create some sub-tables from this. How can I look down the Woollybud column and where ever it says "Woolly bud" tabulate the data from the year column and the ACCUM GDD column that coincides with this and create a second table so I get a summary table: Year ACCUM GDD 1999 32 2000 11.75 2001 35.5 and so on
and likewise for the next column Budburst, create a summary table of Year and ACCUM GDD for Budburst?
Much appreciated, Wendy
0 comentarios
Respuesta aceptada
Steven Yeh
el 20 de Jun. de 2018
You can use the readtable function to build a table first, then retrieve the subtable with conditional indexing.
For example:
A = readtable('Matlab example extract table.xls');
w_table = A(A.Woollybud == "Woolly bud", :);
b_table = A(A.Budburst == "Budburst", :);
Más respuestas (1)
Steven Lord
el 20 de Jun. de 2018
Depending on what you mean by "summary" (compute the average of each table column for each value of your grouping variable, or put all the rows with the same value of your grouping variable together) either groupsummary or sortrows may be of use to you.
1 comentario
Peter Perkins
el 3 de Jul. de 2018
As Steve says, it's often possible to do "groupwise" calculations without actually splitting up your data. If you have a lot of different groups, it's much easier that way.
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!