The splitting step is now a much more reasonable 2.5 seconds.
The remainder of the file is messy for loops which could
probably be made faster if the code was restructured.
The code is full of puzzles such as the following:
iis='i1';
for ii=2:length(w.size);
iis=[iis,',i',num2str(ii)];
end
nn=prod(w.size); %number of elements
eval(['[',iis,']=ind2sub(w.size,[1:nn]);']); % generation of indexes
iis='i1(ind)';
for ii=2:length(w.size);
iis=[iis,',i',num2str(ii),'(ind)'];
end % indexes of indexes
for ind=1:nn
eval(['valor(',iis,')=tag_contents{i,4}(ind);'])
end
if exist('valor')==1;
tag_contents{i,4}=valor;
clear valor;
end
Which as far as I can tell is just:
tag_contents{i,4} = reshape(tag_contents{i,4},w.size);
The latter runs much faster 8-)
With the above transformation, I can now get almost all the way
through in reasonable time.
Now it is hitting a 'max recursion limit exceeded' message in
code even uglier than the above. In addition, I believe this
code relies on the fact that fields in a structure are ordered.