[Top][All Lists]

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

RE: Output format conventions ...

From: Allen.Windhorn
Subject: RE: Output format conventions ...
Date: Fri, 27 Mar 2015 13:41:56 +0000


> -----Original Message-----
> From: address@hidden
> I have a question you (might ...) be able to give me an answer to.
> I use two arrays, say A and B and I initialize them somehow. In
> addition, I make sure they have the same size:
> ...
> 2.) apparently more elegant way ...
>    outfile=fopen("dummy.dat", "w");
>    fprintf(outfile, "%i, %i\n", A, B);
>    fclose (outfile);
> version 2.) does not work, the data in "dummy.dat" will be corrupt.
> However, if I write only one array this way, say
> 3.)
>    outfile=fopen("dummy.dat", "w");
>    fprintf(outfile, "%i\n", A);
>    fclose (outfile);
> the resulting "dummy.dat" is (appears to be ...) correct...

This seems to write all the elements of A first, then all of B.
You could do:

    C = [A, B];
    save -ascii dummy.dat C

But this writes the elements without commas between.  It looks
as if csvwrite is what you want:

    C = [A, B];
    csvwrite("dummy.dat", C)

csvwrite apparently looks for a file name, not for a file handle.


reply via email to

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