Learn to read and write text and data files in MATLAB using fopen, fprintf, fscanf, and fclose.
fclose to avoid memory leaks and file locks.
fopen(filename, mode) — Open a file ('r', 'w', 'a', etc.)fprintf(fid, format, ...) — Write formatted data to a filefscanf(fid, format) — Read formatted data from a filefclose(fid) — Close the open fileload(filename) — Load data from a MAT-file or ASCII data filesave(filename, variables) — Save variables to a MAT-file