MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
11-Jul-2016 2 'b' 8

Sort by the data variables X and Y. sortrows sorts on X first, then on Y.

sortrows(TT,{'X' 'Y'})

ans=8×4 timetable
Date X Y Z
___________ _ ___ _

10-Jul-2016 1 'a' 1
11-Jul-2016 1 'a' 3
10-Jul-2016 1 'b' 2
11-Jul-2016 1 'b' 4
10-Jul-2016 2 'a' 5
11-Jul-2016 2 'a' 7
10-Jul-2016 2 'b' 6
11-Jul-2016 2 'b' 8

Sort by row times and X together.

sortrows(TT,{'Date' 'X'})

ans=8×4 timetable
Date X Y Z
___________ _ ___ _

10-Jul-2016 1 'a' 1
10-Jul-2016 1 'b' 2
10-Jul-2016 2 'a' 5
10-Jul-2016 2 'b' 6
11-Jul-2016 1 'a' 3
11-Jul-2016 1 'b' 4
11-Jul-2016 2 'a' 7
11-Jul-2016 2 'b' 8

Use Row Labels as Grouping or Key Variables

When you group rows together using the rowfun, varfun, stack, and unstack
functions, you can specify row labels as grouping variables. When you join tables or
timetable together using the join, innerjoin, and outerjoin functions, you can
specify row labels as key variables.

10 Timetables

Free download pdf