How to work with Struct With Struct construction
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposta accettata
Jan
il 16 Dic 2021
It is not clear, how the inputs data exactly look and what you want as output. Prefer to post some code, which produces both.
Maybe you want:
C = struct2cell(data);
Result = cat(1, C{:});
5 Commenti
Più risposte (1)
Walter Roberson
il 16 Dic 2021
names = structfun(@(S) S.Name, Data);
values = structfun(@(S) S.Value, Data, 'uniform', 0);
catval = cell2mat(values(:).')
Vedere anche
Categorie
Scopri di più su String Parsing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!