I have a structure with programatically generated fieldnames (let's call it myStruct), and an optimization program (let's call it optfunc) needs to run on data contained in each fieldname. I would like to use parfor to accelerate the process, but the normal way to loop through structs creates unclassified variables. Any tips on how this can be fixed? E.g.:
myFields = fieldnames(myStruct);
nFields = size(myFields,1);
parfor iField = 1:nFields
dataSet = myStruct.(myFields{iField});
optOut = optfunc( dataSet );
end
댓글 수: 1
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/450822-loop-through-structure-elements-with-parfor#comment_682680
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/450822-loop-through-structure-elements-with-parfor#comment_682680
댓글을 달려면 로그인하십시오.