add entry to a table but only for one cell in matlab

To add an entry to a specific cell in a MATLAB table, you can use indexing and cell assignment.

Suppose you have a table T:

main.m
T = table({'John'; 'Jane'; 'Anne'}, [34; 28; 43], [true; false; true]);
T.Properties.VariableNames = {'Name', 'Age', 'Female'};
128 chars
3 lines

To add an entry to the third row, second column (i.e., the age of 'Anne') you can use:

main.m
T{3, 'Age'} = 44;
18 chars
2 lines

This will change the value of the cell at row 3 and column 'Age' to 44.

You can also use the dot notation to access and modify the cell:

main.m
T.Age(3) = 44;
15 chars
2 lines

Both of these methods will achieve the same result.

gistlibby LogSnag