how can i combine 2 structure array in one structure array?

1 view (last 30 days)
Hi i am using gui and in order to see desired results on Workspace i use assignin fucntion.
assignin('base','Info',Info)
assignin('base',meinmappe{i},Readin_parameters)
assignin('base',meinmappe{i},Readin_Headers)
meinmappe is structure Array which must include Readin_parameters and Readin_Headers. However Matlab save just Readin_parameters in to meinmappe{i} but i want both of them. How can i solve this Problem? Readin_Parameter and Readin_Headers are structure Arrays that include more than 100 Parameters (it depends on Experiment results) ant they own their values too. Second Question= Now i am reading like txt files .first Comes Parameters than values.every meauserment file have different numberof values thats why formatSpecification changes. Exmaple: formatSpec4 = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%........%[^\n\r]'; (s* line) how can i define my formatspecification regarding to line number?

Accepted Answer

Guillaume
Guillaume on 5 Mar 2015
Assuming that both structures don't share any field names, you can combine them with this:
combinestructs = @(s1, s2) cell2struct([struct2cell(s1); struct2cell(s2)], [fieldnames(s1); fieldnames(s2)]);
assignin('base', meinmappe{i}, combinestructs(Readin_parameters, Readin_Headers));
As for your second question, pleas post it separately (and format it properly).

More Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!