MATLAB: Txt looks normal on Linux but weird on Windows. WHY

fclosefopenfwritelinuxwindows

I created txt. file using fopen, fwrite and fclose running MATLAB on Linux. However, the lines are mixed up when opening the file on Windows. Is there any work around? I need to be able to work with the txt. file on both WIndows and Linux.

Best Answer

On the Linux side, each place that you currently write out '\n', change it to '\r\n'. That is, instead of char(10) use char([13 10])