help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing a commented output to file


From: Jaroslav Hajek
Subject: Re: Writing a commented output to file
Date: Wed, 6 May 2009 12:56:21 +0200

On Wed, May 6, 2009 at 12:38 PM, AlexG1 <address@hidden> wrote:
>
>
>
> John W. Eaton-3 wrote:
>>
>>
>> Here's one more way:
>>
>>   fid = fopen ('foo.dat', 'w');
>>   fprintf (fid, '%% Some comment 1\n%% Some comment 2\n');
>>   nc = size (x, 2);
>>   fmt = sprintf ('%s\n', repmat ('%f ', [1, nc]));
>>   fprintf (fid, fmt, x');
>>
>>
>>
>
> Thanks, works great.
> There's something I didn't understand though - can you please explain why
> the transpose on the fprintf() call is needed?

because fprintf always traverses the data in the memory storage order,
i.e. columns first (as if "x(:)" was used).

regards

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

[Prev in Thread] Current Thread [Next in Thread]