Writing a commented output to file
Jaroslav Hajek
highegg at gmail.com
Wed May 6 05:56:21 CDT 2009
On Wed, May 6, 2009 at 12:38 PM, AlexG1 <alxgel at gmail.com> 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
More information about the Help-octave
mailing list