MATLAB Answers

Changing format of a Struct

36 views (last 30 days)
Cameron Kirk
Cameron Kirk on 7 Jan 2020
Answered: Andrew Janke on 31 Jan 2020
Hi,
I am just looking to change the format of my struct That I have at the moment.
So currently, I have a 7x1 Struct with 6 fields Struct.png
However, I want to change this to become a 1x1 struct with 6 fields, with the fields in the left hand side
Here is an example of how I would like my struct to look like Struct 3.png
How do I go about changing this?
Thanks!
  6 Comments
Cameron Kirk
Cameron Kirk on 10 Jan 2020
No problem,
Thanks for answering my question, I think it was a problem on my part.

Sign in to comment.

Answers (1)

Andrew Janke
Andrew Janke on 31 Jan 2020
You should consider using a Matlab table array instead of a struct for cases like this. They're more suitable for data in this format: it'll give you data shape validation and friendlier display output.

Community Treasure Hunt

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

Start Hunting!

Translated by