fprintf not printing new line

前端 未结 2 1170

I am trying to send an array that is [2 x N] doubles large to a text file using the fprintf() command. I am having problems in that fprintf() is no

相关标签:
2条回答
  • 2021-01-05 19:22

    An alternative solution is to open the file in text mode, that way MATLAB automatically inserts a carriage return \r before any newline \n character in the output on Windows systems:

    fid = fopen('file.txt', 'wt');
    fprintf(fid, '%f\t%f\n', rand(10,2));
    fclose(fid);
    

    Note that this is somewhat unnecessary, since most editors (with the exception of Microsoft Notepad) recognize Unix/Mac/Windows line endings.

    0 讨论(0)
  • 2021-01-05 19:24

    I know that on many systems, \n is not enough to create what you're asking for (and so, maybe you have to do \r\n)

    0 讨论(0)
提交回复
热议问题