Why does the "-ASCII" option flag with the SAVE function add extra end-of-line characters in MATLAB?
When I create or load data into MATLAB and then write it out to a file using the SAVE function with the -ascii option flag, it adds extra characters to the end of each row of data. This behavior did not happen in versions of MATLAB previous to MATLAB 6.1 (R12.1).
The code below replicates this behavior:
% First create some data
h = rand(15,2);% Now save h in ASCII format to a .dat file
save newoutput.dat h -ascii
Now open newoutput.dat in Notepad. You will notice that at the end of each row of data, an extra character has been appended. This extra control character has the appearance of having been generated in UNIX.
Note, however, that the output looks correct if you open it within Wordpad.
Best Answer