MATLAB: How to export result of the script to txt/doc file

MATLABscripttext file

I have a script with several sprintf commands. How to write them automatically to external text file after running the script?

Best Answer

Use the fopen (link) command to create a file identification number. Then use the file identification number in your fprintf (link) calls to print to a file.
Copy your sprintf calls to fprintf calls, since they use the same essential syntax, other than fprintf using the file identification number.
Related Question