Why does table2struct not produce the inverse of struct2table?

5 views (last 30 days)
When I convert a structure to a table using struct2table, the original is not returned by using table2struct. I have a 1x1 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 207x1 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?

Accepted Answer

Adam
Adam on 9 Jan 2015
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.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!