MATLAB: Printing answers in a word doc

fsolveMATLABword doc

Hello community,
I am trying to write a code that prints the solutions of system of nonlinear equations into a word doc. I wrote a code that successfully solves for the variables but I am having trouble printing these values into a word doc.
I created the following code:
function F = SL10B(x)
Lab = .1;
Lbc = .6;
Lcd = .3;
Lad = .4;
rabx = Lab*cosd(0);
raby = Lab*sind(0);
F = [ (x(1))^2 + (x(2)^2)- Lbc^2;
(x(3))^2 + (x(4))^2 - Lcd^2;
raby + x(2) + x(4);
rabx + x(1) + x(3) - Lad];
fid = fopen('Solutions.doc','w');
fprintf(fid,'iteration x1 x2 x3 x4 \n');
fprintf(fid,'_______________________________________________________\n')
tab=[x(1);x(2);x(3);x(4)];
fprintf(fid,'%5d %9.2f %8.3f %8.3f %12.4f\n', tab);
end
A word doc opens but nothing is printed on it. How could I fix this?
Thank you.

Best Answer

Fabiano - while you have given the extension of doc to your file, it won't be a Word document that you are creating but just at text file. Is this sufficient?
As for the reason as to why the file is empty, it is most likely because you haven't closed the file that is identified by fid. Use fclose to close the file once you have finished writing all text to the file as
fclose(fid);