how can i combine 2 structure array in one structure array?
2 次查看(过去 30 天)
显示 更早的评论
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?
采纳的回答
Guillaume
2015-3-5
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).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle Swarm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!