fprintf function - File function:
The fprintf function really returns the number of bytes which was written to the file, therefore if you do not want to see that number, suppress the output with a semicolon as shown here. (Note: Whenever writing to the screen, the value returned by fprintf is not visible, but could be stored in the variable.)
Here is an illustration of writing to a file named 'tryit.txt':
>> fid = fopen('tryit.txt', 'w');
>> for i = 1:3
fprintf(fid,'The loop variable is %d\n', i);
end
>> fclose(fid);