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: fprintf is not reading the \n
Replies: 2   Last Post: Jun 30, 2012 2:01 PM

Advanced Search

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

Posts: 15
Registered: 6/18/12
Re: fprintf is not reading the \n
Posted: Jun 30, 2012 9:15 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Fri, 29 Jun 2012 14:41:23 -0500, dpb wrote:

> On 6/29/2012 2:08 PM, anyone wrote:
>> On Fri, 29 Jun 2012 18:41:18 +0000, Ellen wrote:
>>> I need to have a matrix output to a file, ...
> ...
>>> fprintf(fid,'%d','%d \n',First);
> ...
>>> It is just printing it as one long string of numbers.
>>
>> Naturally, since that is what you asked Matlab to do.

>
> That's kinda' snarky... :(

>> [...]
>>> Someone was suggesting something about how it needs to read and print
>>> the data line by line, however I don't know how to do that.

>>
>> Try something like this:

> ...
>> for i = 1:7480
>> fprintf(fid,'%14.10e %5.2f\n',First(i,1),First(i,2));

> ...
>
> Not "_the_Matlab_way_" -- no loop needed. Use ' operator. See other
> response.


"...something like..." does not imply 'the only way', does it?



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.