Create a subtable from a larger table

조회 수: 194 (최근 30일)
Wendy Cameron
Wendy Cameron 2018년 6월 20일
댓글: Peter Perkins 2018년 7월 3일
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

채택된 답변

Steven Yeh
Steven Yeh 2018년 6월 20일
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", :);
  댓글 수: 1
Wendy Cameron
Wendy Cameron 2018년 6월 20일
Thanks very much Stephen that works. If it is a table with many more columns I can then just extract the columns I want. I am slowly learning! Much appreciated.
Kind regards, Wendy

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2018년 6월 20일
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
Peter Perkins
Peter Perkins 2018년 7월 3일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by