Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all
I am trying add my data to a file during run of a recursive function in Matlab
but unfortunately while adding data in text file by dlmwrite() function just the last data was added.
the below code is my code

VB
for i=1:7
    dlmwrite('m.txt',i);
end



thanks all.
Posted
Updated 17-Feb-15 8:33am
v2
Comments
Sergey Alexandrovich Kryukov 17-Feb-15 17:33pm    
Why recursive? What is the purpose? What should be written, especially what is related to recursion?
—SA

1 solution

A quick look at the documentation would have told you what the problem was.
http://uk.mathworks.com/help/matlab/ref/dlmwrite.html[^]

dlmwrite(filename,M) writes numeric data in array M to an ASCII format file, filename, using the default delimiter (,) to separate array elements. If the file, filename, already exists, dlmwrite overwrites the file.
Instead use:
dlmwrite(filename,M,'-append') appends the data to the end of the existing file, filename.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900