Fprintf does not print a new line

I am trying to send an array that [2 x N] doubles a large size to a text file using the command fprintf(). I'm having trouble fprintf()not recognizing a new command line ( \n) or carriage return command ( \r). The code I'm using is

fid = fopen([Image.Dir,'CtlPts_',Image.Files{k},'.txt'],'w');
fprintf(fid,'%.4f\t%.4f\n',control_points{k});
fclose(fid);

where the data I'm trying to print is in a cell control_points{k}.

The tab printed fine, but everything in the text file is printed on one line, so I assume that it ignores my new line character.

Is there something wrong with my syntax that I can't see?

+5
source share
2 answers

, \n , (, , \r\n)

+10

open , MATLAB \r \n Windows:

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

, , ( Microsoft Notepad) Unix/Mac/Windows.

+8

All Articles