Check out example codes for "fprintf in directory matlab". It will help you in understanding the concepts better.

Code Example 1

fid = fopen('C:\abcd.txt','w+');
fprintf(fid, '%s\n', 'SampleText');
fclose(fid)

Learn ReactJs, React Native from akashmittal.com