🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

file write problem

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

The made a below script.

When I see the read3.txt file it has different show.

 

['notepad program']

It doesn't have a line change.

image.png.9f76f7185a7af589a1d331d950e12534.png

 

['notepad++ program']

It has a line change

image.png.4b60b7ddadc38fa01f7da81b55963541.png

 

 

How can I make a read3.txt file to be read same as 'notepad++ program'   at 'notepad program'.

 

 

file = 'read3.txt';
fid = fopen(file, 'w');
AA=[1,2;3,4;5,6];


for i=1:3
fprintf(fid,'%f %f \n', AA(i,:)); 
end


fclose(fid);

 

 

 

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "Matthieu Pupat"
    Altair Employee
    Updated by Matthieu Pupat

    This is because Notepad can only properly display files with Windows newline (CR+LF).

    The code you use produces UNIX newline (LF only).

     

    In Notepad++, you can control which end-of-line is used in your file by going to Edit > EOL Conversion. The greyed entry is your current end-of-line.

     

    To make Compose write a Windows EOL, that will be displayed as you expect in Notepad, please use the following code:

     

    file = 'read3.txt';
    fid = fopen(file, 'w');
    AA=[1,2;3,4;5,6];


    for i=1:3
    fprintf(fid,'%f %f \r\n', AA(i,:));
    end


    fclose(fid);

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Thank you Matthieu Pupat.