MATLAB: Write string in text file

fprintf text

How can I write some strings in text file (each strinng in one line)? example:
Happy
New
Year

Best Answer

Try this:
fid = fopen('ny.txt','wt');
fprintf(fid, 'Happy\nNew\nYear');
fclose(fid);