To convert a structure into a table without variable names in Matlab, you can use the struct2cell
function to convert the structure to a cell array, and then use that to create a table using the cell2table
function. Here's a code example:
main.m146 chars4 lines
Here, the struct2cell
function converts myStruct
to a cell array structCells
, where each field of the structure is in a separate cell. The transpose of structCells
is passed to cell2table
, which creates a table with no variable names.
Note that when you create a table with no variable names, you won't be able to access the fields of the table using dot notation (table.field1
), but you can access them using indexing (table{:, 1}
).
gistlibby LogSnag