add entry to table in matlab

To add an entry to a table in Matlab, you can use the syntax:

main.m
table_name{row_number, 'column_name'} = value;
47 chars
2 lines

where table_name is the name of your table, row_number is the index of the row where you want to add the entry, column_name is the name of the column where you want to add the entry, and value is the value that you want to add.

Here's an example:

main.m
% Create a sample table
T = table({'M';'F';'F';'M'},[38;43;38;40],[71;68;67;73],'VariableNames',{'Gender','Age','Height'})

% Add an entry to the table
T{5, 'Gender'} = 'F';
174 chars
6 lines

In this example, we create a table T with 3 columns (Gender, Age, and Height) and 4 rows. Then, we add a new entry to the Gender column in the 5th row with the value 'F'.

Note that if the row or column doesn't exist, Matlab will automatically add it for you.

related categories

gistlibby LogSnag