The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Unable to get new line fprintf
Replies: 6   Last Post: Aug 25, 2014 1:15 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,850
Registered: 6/7/07
Re: Unable to get new line fprintf
Posted: Mar 15, 2013 1:59 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 3/15/2013 12:44 PM, Ravin wrote:
> Hi i have written a code to write data into a text file:
> fileID = fopen('testWrite.txt','w'); mystring = 'aX';
> fprintf(fileID,'%s\n',['Name: ',mystring]); fprintf(fileID,'%d',21);
> I get the result:
> Name: aX21
> instead of
> Name: aX
> 21
> Can anyone explain this to me?


As a guess the lack of the 't' on the fopen in 'wt' maybe resulted in
the \n not being correct for the display software/editor used to look
at/open the resulting file.


fileID = fopen('testWrite.txt','wt');

and let us know if that doesn't fix the problem.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.