Changing format of a Struct

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 Commenti

Guillaume
Guillaume il 7 Gen 2020
There seems to be nothing in common between your input structure and your desired output structure, so please explain the context for your question.
Hi Guillaume,
The bottom image (I understand the field names/contents are different), but that is what I would like to format the struct in the first image so it would look like in a 1x1 struct:
field Value
name
folder
date
bytes
isdir
datenum
I hope this helps
Stephen23
Stephen23 il 7 Gen 2020
And the elements of the structure would be listed as columns?
Hi Stephen,
That is correct,
thanks
Guillaume
Guillaume il 7 Gen 2020
Modificato: Guillaume il 7 Gen 2020
Ok, now I'm even more confused. Note that a structure doesn't have a format. The screenshots you show is how the structures are displayed by the variable editor. If the structure is an array, the variable editor shows the fields as column header and the structure elements as rows. If the structure is scalar, then the variable editor shows the fields in a single column and the values in another. That's just for display in the variable editor, fields are neither columns or rows.
If you are asking how to change the display of a structure array in the variable editor so that it looks like your 2nd screenshot, then the answer is simple: you can't, it's not customisable. You only get that display with scalar structure (e.g. assign matfile(1) to a variable and it'd look like that).
Cameron Kirk
Cameron Kirk il 10 Gen 2020
No problem,
Thanks for answering my question, I think it was a problem on my part.

Accedi per commentare.

Risposte (1)

Andrew Janke
Andrew Janke il 31 Gen 2020

0 voti

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.

Richiesto:

il 7 Gen 2020

Risposto:

il 31 Gen 2020

Community Treasure Hunt

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

Start Hunting!

Translated by