Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

Topic: Unable to get new line fprintf
Replies: 5   Last Post: Mar 17, 2013 9:46 AM

Advanced Search

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

Posts: 7,853
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.

Try

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.