subscripting into a table using three or more subscripts (as in t(i,j,k)) is not supported. always specify a row subscript and a variable subscript, as in t(rows,vars). in matlab

In MATLAB, indexing a table using three or more subscripts is not supported. That means you cannot use the syntax t(i,j,k) to select specific elements from a table t. Instead, you should always specify a row subscript and a variable subscript (also known as a column subscript), using the syntax t(rows,vars). This means you can select one or more rows from the table and one or more variables from those rows. Here is an example:

main.m
% create a sample table
t = table([1;2;3],[4;5;6],[7;8;9],'VariableNames',{'A','B','C'});

% index the table using two subscripts (one for rows, one for variables)
t_rows = [2 3];
t_vars = {'B' 'C'};
subset = t(t_rows,t_vars)

% Output:
%  B C
%  - -
%  5 8
%  6 9
265 chars
14 lines

In the example above, we create a table t with three variables (A, B, and C) and three rows. We then select rows 2 and 3 and variables B and C using the t(2:3,{'B','C'}) syntax. The resulting subset of the table contains the selected rows and variables.

related categories

gistlibby LogSnag