MatLab 2017b中 \r与\n的用法举例
结果分别用记事本、MatLab编辑器、Edit++打开
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp1.txt', 'wt');
fprintf(fid, '%6.2f %12.8f\r', y);
fclose(fid)
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp2.txt', 'wt');
fprintf(fid, '%6.2f %12.8f\n', y);
fclose(fid)
x = 0:.1:1;
y = [x; exp(x)];
fid = fopen('exp3.txt', 'wt');
fprintf(fid, '%6.2f %12.8f\r\n', y);
fclose(fid)