I'd like to create a loop that each time adds a new line to a .txt file.
Show older comments
I have a loop that generates a vector each time it loops through .
my_vector = [ 4, 5, 6,7];
I'd like to create a loop that each time adds the new vector to a .txt file.
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 28 Oct 2013
Look at this example
fid=fopen('file.txt','w')
for k=1:10
my_vector=randi(4,1,4)
fprintf(fid,'%f %f %f %f \r\n',my_vector)
end
fclose(fid)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!