Path: news.mathworks.com!not-for-mail
From: "Rick Rosson" <rrosson@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Complex structure to text file
Date: Thu, 9 Aug 2007 16:26:34 -0400
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <f9ft9s$lka$1@fred.mathworks.com>
References: <f9fq2l$2vi$1@fred.mathworks.com>
Reply-To: "Rick Rosson" <rrosson@mathworks.com>
NNTP-Posting-Host: rossonr.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1186691196 22154 144.212.206.185 (9 Aug 2007 20:26:36 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 9 Aug 2007 20:26:36 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:423262



As an example, you could try something like this:

    imchar = 'j';

    [ M N ] = size(X);

    filename = 'myData.txt';
    fid = fopen(filename,'w');

    for row = 1:M

        for col = 1:N
            fprintf(fid,'%f + %f%c 
',real(X(row,col)),imag(X(row,col)),imchar);
        end

        fprintf(fid,'\n');

    end

    fclose(fid);


where 'X' is an array of complex-valued numbers.


Rick



"Anthony " <anthony.campos@baesystems.com> wrote in message 
news:f9fq2l$2vi$1@fred.mathworks.com...
>I am trying to take a data that's in a matrix in matlab and
> output it to a file.  In each cell there is a complex
> number. Is there a way to write this complex number to a
> file? and maintain the precision, or change the precision?