how to get a single value of a row from a table in matlab

Assuming you have a table T and you want to get the value of a specific row i and column columnName, you can use the following code:

main.m
value = T{i, 'columnName'}
27 chars
2 lines

For example, consider the following table T:

| Name | Age | Gender | |-------|-----|--------| | John | 23 | M | | Alice | 30 | F | | Bob | 45 | M |

If you want to get the age of Alice, you can do:

main.m
age = T{2, 'Age'} % age will be 30
35 chars
2 lines

related categories

gistlibby LogSnag