Re: how to write a matlab matrix to a txt file



In article <ef5c1ff.-1@xxxxxxxxxxxxxxxxxxxxxxx>,
kadir <kkirtacremovethis@xxxxxxxxx> wrote:
Hi, i try to use fwrite function but it changes the data format and
when i open the file via notepad , some weird characters shown.
fprintf function also writes the matrix as a column or row vector to
a txt file, a 200x3 matrix becomes 600x1 in the txt file. So, how can
i write the matlab data "as is" to a txt file ? thnx

4. FPRINTF is "vectorized" for the case when A is nonscalar. The
format string is recycled through the elements of A (columnwise)
until all the elements are used up. It is then recycled in a similar
manner through any additional array arguments.

So try something like

fprintf(outputstream, [repmat('%f ', 1, size(A,2)), '\n'], A');
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
.



Relevant Pages

  • Re: string length limitation of printf
    ... > Does 509 appear in any C standard? ... 14 The fprintf function returns the number of characters ... 15 The number of characters that can be produced by any single ... any single conversion shall be 509. ...
    (comp.lang.c)
  • Re: string length limitation of printf
    ... > From the 1999 standard: ... > 14 The fprintf function returns the number of characters ... > 15 The number of characters that can be produced by any single ... > any single conversion shall be 509. ...
    (comp.lang.c)
  • Re: Is My Program OK?
    ... if an encoding error occurred. ... The fprintf function returns the number of characters ... The printf function returns the number of characters ...
    (comp.lang.c)
  • Re: EOF from printf
    ... When "printf" returns EOF the function has already failed. ... The fprintf function returns the number of characters ...
    (comp.lang.c)