Click here to Skip to main content
12,304,763 members (63,912 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Matlab file Text
Hello

How can i write to a text file every time start from the next line, for example say i have a text file "test.txt" and i have an iterative code that prints say "hello" what i want is hello to be print on next line every time like this

hello
hello
hello

so far i have used
 ta='text.txt';
fid = fopen((ta), 'a');
Loop{ fprintf(fid,'%s\n',word); }
any help is warmly appreciated.
Posted 11-Oct-12 23:50pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

In my opinion your loop never ends... Why? Read more about loops: http://www.mathworks.com/help/search/doccenter/en/R2012b?qdoc=loops&submitsearch=Search[^]

If you would like to write the data at the end of existing file, read this: http://www.mathworks.com/help/matlab/import_export/writing-to-text-data-files-with-low-level-io.html#br5_kad-1[^]
  Permalink  
Comments
Sergey Alexandrovich Kryukov 12-Oct-12 14:30pm
   
He-he, right, a 5. I'm just feel awkward to recommend anything in particular. With this level, I cannot be sure the whole thing makes sense.
--SA
Maciej Los 12-Oct-12 14:34pm
   
;) Yes, it's true ;)
Thank you, Sergey.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100