concatination of matalb structures with diffrent set of fields in recursive call
Show older comments
I have a recursive function that i use to explore diffrent parallel problems, then each probelm may have diffrents parallel solutions, then I have to store the solutions in the same structure. This is my code witch works well if the the pblems Have juste one solution but when it parallel I get the folowing error "Number of fields in structure arrays being concatenated do not match. Concatenation of structure arrays requires that these arrays have the same set of fields.
"
here is my function code
function Result =RecursiveProgramTest(Sol,Concept_matrix,FPrime,Concept,Level,EndFPrime,EndFPrimeLast,s)
[Levelbis,NumberofParallelLevel,EndFPrime,IndexToDelete] = ServiceSemanticMatchingFunction(Sol.UR.Plus.Ancestors.Name,Sol.UR.Plus.Concept,Concept_matrix,FPrime,length(FPrime),Concept,EndFPrime,s,Level);
if isempty(Levelbis) || EndFPrime==EndFPrimeLast
Result.AS=[];
Result.UR=[];
else
if length(Levelbis)==1
FPrime(IndexToDelete)=[];
AbstactCompositionPlan.AS=Levelbis;
Variable.Concept.Name = Levelbis.Outputs.Name;
Variable.Ancestors.Name =Levelbis.Outputs.Ancestors.Name;
AbstactCompositionPlan.UR.Plus = Variable;
Result= cat(1,AbstactCompositionPlan,RecursiveProgramTest(AbstactCompositionPlan,Concept_matrix,FPrime,Concept,Level,EndFPrime,EndFPrimeLast,s));
EndFPrime= EndFPrime+1;
else
FPrime(IndexToDelete)=[];
for i=1:length(Levelbis)
x=i
EndFPrimeParellel{i}=EndFPrime;
AbstactCompositionPlan(i).AS=Levelbis(i);
Variable(i).Concept.Name =Levelbis(i).Outputs.Name;
Variable(i).Ancestors.Name =Levelbis(i).Outputs.Ancestors.Name;
AbstactCompositionPlan(i).UR.Plus = Variable(i);
FPrimeParalell{i}=FPrime;
Result.AS{i}= cat(1,AbstactCompositionPlan(i),RecursiveProgramTest(AbstactCompositionPlan(i),Concept_matrix,FPrimeParalell{i},Concept,Level,EndFPrime,EndFPrimeLast,s));
EndFPrimeParellel{i}= EndFPrimeParellel{i}+1; % le metre en parl
end
end
end
Here some figures to show he result, wel the first 6 problem have not parallel solution so there is no problem
, but the 7 probelm have 3 parallel solutios
, so the cancatination in the recursive cal under the loop get me the error.
, but the 7 probelm have 3 parallel solutios
, so the cancatination in the recursive cal under the loop get me the error.If anywone can help me I will be very gratful
Accepted Answer
More Answers (0)
Categories
Find more on Structures 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!