To get only one field from a cell in MATLAB, you can use curly braces {} with the name of the cell and the index of the element you want to access. For example, let's say you have a cell my_cell containing several elements, and each element is a struct with a field named my_field. To get the value of the my_field field from the first element of the cell, you can do:
main.m110 chars3 lines
In this example, my_field_value will be 'value1'. Here, we first create a cell my_cell containing two elements, which are both structs with a single field my_field. Then, we use curly braces {} to access the first element of my_cell, which is itself a struct. Finally, we use dot notation to access the my_field field of the struct, which gives us the value 'value1'.
Note that curly braces {} are used for indexing into cells, while parentheses () are used for indexing into arrays. If you have a struct array instead of a cell array, you can also use parentheses to access a particular field of an element. For example:
main.m106 chars3 lines
Here, my_field_value will be 'value1'.
gistlibby LogSnag