How to create a table from a bigger table based on category ?

I am working on a data set which I imported to a table from a csv file. The table contains 8 columns. The data type of the columns is as follows : one column is categorical while the other columns are number (double). I would like to create sub tables, each one corresponds to a category. Anyone to help do that. Thanks in advance>

 Accepted Answer

You probably do not want to do that, but there's not enough information to go on.
In any case
T2 = T(T.C == 'somevalue',:)
does what you are asking. But you probably do not need to do that. You will end up with a bunch of separate tables. You are likely better off having one table, and doing grouped calculations with things like varfun or splitapply.

3 Comments

Thanks for taking the time to answer me. I have already tried what you proposed but it didn't work. Let me give you more details. Actually, I am working on a time series data set of airplane flight parameters. The data set includes data related to hundreds of airplanes, hence, I want to group each airplane data in a table. I chose to set the airplane registration number as the criteria of grouping and I set it as "categorical". T2 = T(T.C == 'somevalue',:) This line only works in case you know how many airplane you have in the data set which is not my case. I hope that I gave you enough information now, thanks again !!
Depending on what computations you want to perform on each grouped airplane data can try using groupsummary on the entire table.
I want to apply Kalman Filters to each flight for position prediction

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!