这是我得到的代码,但是运行时间太长。如何通过删除嵌套的 for 循环来加快速度?
for iGroup = 1:length(groupIndices)
curGroupIndex = groupIndices(iGroup);
curChanIndices = chanIndices{iGroup};
curChanNames = chanNames{iGroup};
groupPropStruct = propsToStruct(propNames{curGroupIndex},propValues{curGroupIndex},REPLACE_STR,PREPEND_STR,ALWAYS_PREPEND);
groupStruct = struct('name',groupNames(iGroup),'props',groupPropStruct);
for iChan = 1:length(curChanIndices)
curChanIndex = curChanIndices(iChan);
chanPropStruct = propsToStruct(propNames{curChanIndex},propValues{curChanIndex},REPLACE_STR,PREPEND_STR,ALWAYS_PREPEND);
chanStruct = struct('name',curChanNames{iChan},'props',chanPropStruct,...
'data',[]);
chanStruct.data = data{curChanIndex};
groupStruct.(TDMS_genvarname2(chanStruct.name,...
REPLACE_STR,PREPEND_STR,ALWAYS_PREPEND)) = chanStruct;
end
output.(TDMS_genvarname2(groupStruct.name,...
REPLACE_STR,PREPEND_STR,ALWAYS_PREPEND)) = groupStruct;
end