Search All of the Math Forum:

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

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

Topic: fprintf is not reading the \n
Replies: 25   Last Post: Jul 2, 2012 11:00 AM

 Messages: [ Previous | Next ]
 anyone Posts: 16 Registered: 6/18/12
Re: fprintf is not reading the \n
Posted: Jun 30, 2012 9:16 AM

On Fri, 29 Jun 2012 19:10:12 -0500, dpb wrote:

> On 6/29/2012 2:41 PM, 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.

>
> BTW, just a couple stylistic comments...
>
> 'i' in Matlab is the imaginary i,

So is 'j'. Those who understand what they're doing aren't terribly
disturbed by the choice.

Date Subject Author
6/29/12 Ellen
6/29/12 dpb
6/29/12 anyone
6/29/12 dpb
6/29/12 Ellen
6/29/12 dpb
6/29/12 dpb
6/30/12 anyone
6/30/12 Doug Schwarz
6/30/12 dpb
6/30/12 dpb
6/30/12 Nasser Abbasi
6/30/12 dpb
7/2/12 anyone
6/30/12 dpb
6/30/12 Doug Schwarz
7/1/12 dpb
7/1/12 dpb
7/1/12 dpb
7/1/12 Doug Schwarz
7/1/12 dpb
7/2/12 Steven Lord
7/2/12 dpb
7/2/12 Steven Lord
6/29/12 anyone
6/29/12 anyone