I think you should consider using structure with dynamic field names (see more details here).
For example
for h=1:n
dataName = sprintf('data%d', h); %// dynamic name
resultName = sprintf('res%d', h); %// dynamic name
base.(resName) = myFunction( base.(currentName) ); %// process data and save to result
end
The nice thing about this approach (especially if you run into memory problems) is that save and load supports this approach:
for h=1:n
dataName = sprintf('data%d', h); %// dynamic name
base = load( 'myHugeMatFile.mat', dataName ); %// loads only one variable from the file
%// now the variable is a field in base
resultName = sprintf('res%d', h); %// dynamic name
base.(resName) = myFunction( base.(currentName) ); %// process data and save to result
save( 'myResultsFile.mat', '-struct', '-append', 'base' ); %// please verify this works - I'm not 100% certain here.
end
Note how save and load can tread struct fields as different variables when needed.
sprintfandfprintf. I could mentioneval, but then I would get comments sayingevalis evil!evalis evil!!! this is why you get these comments! use struct with dynamic field names instead