MATLAB: Does table2struct not produce the inverse of struct2table

table2struct invert struct2table

When I convert a structure to a table using struct2table, the original is not returned by using table2struct. I have a 1×1 structure which shows 41 fields when displayed in Workspace, each of which has 207 data values – some are cell some are numeric.
If I convert this using struct2table, and then convert it back using table2struct, I do not get the original structure, but rather a 207×1 structure which has 41 fields. It does not index the same as the original, and so can not be passed on to other functions in the same way.
Why is this and how can I get my original back?

Best Answer

Try using the
S = table2struct(T,'ToScalar',true)
option as shown on the help page
doc table2struct.
This sounds like it does what you are after.