How to create a struct?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
How can i split my "scenarioServiceCopy" 1*54 struct in two parts? For example:
- 1-30 fields -> part 1
- 31-54 fields in part 2
In this way i store the data in my struct:
parameter.scenarioServiceCopy(count).(namess{7})=char(array_(1,7))
I do this with a for loop. It works but everything is in one "matrix/table/struct".
I want to have something like this:
- part 1 first 30 fields: parameter.scenarioServiceCopy(1)
- part 2 the last 24 fields: parameter.scenarioServiceCopy(2)
But does something like this works
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333096/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333099/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/333102/image.png)
Thanks
3 Kommentare
Walter Roberson
am 18 Jul. 2020
How should 54 input fields map on to 2*85 with 16 fields?
v = fieldnames(scenarioServiceCopy);
tc = struct2cell(scenarioServiceCopy);
p1 = cell2struct(tc(1:30,:,:),v(1:30));
p2 = cell2struct(tc(31:end,:,:), v(31:end));
parameter.scenarioServiceCopy1 = p1;
parameter.scenarioServiceCopy2 = p2;
Antworten (1)
Bhupendra Prajapati
am 17 Jul. 2020
Bearbeitet: madhan ravi
am 17 Jul. 2020
parameter = struct(scenarioServiceCopy(1),scenarioServiceCopy(2));
Just follow the exmaples given at the link below ->
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!