[Top][All Lists]

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

Output format conventions ...

From: address@hidden
Subject: Output format conventions ...
Date: Fri, 27 Mar 2015 07:33:23 +0100

Dear listmembers,
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:


for i=1:1024

Now I want to write those data to a file. I see two options:

1.) "standard C" - way ....
   outfile=fopen("dummy.dat", "w");
   for i=1:1024
        fprintf(outfile, "%i %i\n", A(i), B(i));
   fclose (outfile);

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

   outfile=fopen("dummy.dat", "w");
   fprintf(outfile, "%i\n", A);
   fclose (outfile);

the resulting "dummy.dat" is (appears to be ...) correct. So, why does 3.)
work but 2.) does not work even though the arrays have the same size, and,
even more important - where would I find an hint what is acceptable and what
is not with regard to such kind of vectorization? Is this a bug or is this
expected to occur? Sorry, I am coming from a "C" - background - how would I do
something like this in a more elegant / simply better way?

Many thanks for your help,
take care

Dieter Jurzitza

reply via email to

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