Note that if the fieldnames really are numbered like that then a much better solution would be to consider using anon-scalar array. A non-scalar structure is a much better way to store data, compared to numbered fieldnames. Using a non-scalar structure would avoid having to perform slow and complicated tricks like this, instead you could use the neat and fast methods shown in the link:
>> S(1).f = 'Hello';
>> S(2).f = 'World';
ans = HelloWorld
See how choosing the best data storage makes a huge difference to the quality of code!