Check out example codes for "save a text matlab". It will help you in understanding the concepts better.

Code Example 1

fileID = fopen('A.txt','w');
fprintf(fileID,'%15s %15s %15s\r\n','x','y','z');
nbytes = fprintf(fileID,'%15d %15d %15d\n',A)
fclose(fileID);

Learn ReactJs, React Native from akashmittal.com