"Able to get the file opening to work"
Well, no, not really. What you've done is alias sprintf to a variable by assigning it in what looks to be array indexing syntax--
fname=['filei' num2str(i) 'j' num2str(j) '.txt'];
>> whos sprintf
Name Size Bytes Class Attributes
sprintf 105x1 840 double
>> which sprintf
sprintf is a variable.
Do you really need all these files open at one time would be first question...but if do, keep the handles in an array...
I don't know what part the fidsum variable was to play so left it out...
Now, when you're ready to write to one of these, then you'd have to know which i, j index pair you want and would write something like
but it's highly unlikely you really, really need that many files at once.
What is the actual end objective you're wanting to output? Almost certainly there's a far better way to construct the logic to do so.