MATLAB: Am I getting ‘ans=45’ in this code

codeMATLAB

I am trying to make a file named text.txt and write numbers 1 to 5 in it, and then print them.
x = [1 2 3 4 5]
a = fopen('test.txt','w');
fprintf(a,'%f\n',x)
fclose(a);
The output I'm getting is:
x =
1 2 3 4 5
ans =
45
Why am I getting ans = 45 ? Neither have I used a variable named ans, nor defined any function in it.

Best Answer

fprintf() reports the number of bytes written. If you don't end that line with a semicolon, it will get reported to the command window. Use a semicolon at the end of the line to suppress that if you don't want it.