How to work with Struct With Struct construction
Show older comments
Hello.
I converted json.data to string and converted string to struct using jsondecode. Got the next struct like:
data =
struct with fields:
A1: [1×1 struct]
A2: [1×1 struct]
A3: [1×1 struct]
A4: [1×1 struct]
A5: [1×1 struct]
A6: [1×1 struct]
How to work with this construction, I mean let's say i need data from A1: [1x1 struct] (this structure contains the name of the variables and its value). How can I get it?
And can I convert this construction to massive with A1 ... A2 - rows and data from [1x1 struct] - columns?
Accepted Answer
More Answers (1)
Walter Roberson
on 16 Dec 2021
names = structfun(@(S) S.Name, Data);
values = structfun(@(S) S.Value, Data, 'uniform', 0);
catval = cell2mat(values(:).')
1 Comment
Ivan Ivan
on 16 Dec 2021
Categories
Find more on JSON Format 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!