index the first 7 rows of a table in matlab

To index the first 7 rows of a table in MATLAB, you can use the following code:

main.m
% create an example table
T = table(randn(10,1), randn(10,1), randn(10,1), 'VariableNames', {'Var1', 'Var2', 'Var3'});

% index the first 7 rows
T(1:7,:)
154 chars
6 lines

The code above creates an example table T with 10 rows and 3 variables. To index the first 7 rows of T, we use T(1:7,:) which returns a new table consisting of the first 7 rows and all variables.

related categories

gistlibby LogSnag