MATLAB: Add new line inside text file

text file

Dear All,
I have a txt file containing:
a, b, c, d, e, f, g, h, i
I have an iteration:
for i=1:10
for j=1:10
dlmwrite('mydata.txt', myvar, '');
end
end
The problem is that it overwrite what I already have in my txt file and it only writes the last value.
What I want as a result in my mydata.txt is something like:
a, b, c, d, e, f, g, h, i
1, 3, 6, 4, 8, 1, 8, 9, 0
2, 5, 6, 7, 5, 4, 2, 9, 4
Thank you and regards, Sypou

Best Answer

See
>> doc dlmwrite
Use dlmwrite with -append option.
Correct format --> dlmwrite(filename, M, '-append')