Path: news.mathworks.com!not-for-mail
From: "Prabhat Shankar" <prabhat4686@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Complex structure to text file
Date: Fri, 20 Jun 2008 14:47:02 +0000 (UTC)
Organization: IIT KGP
Lines: 19
Message-ID: <g3gft6$hgo$1@fred.mathworks.com>
References: <f9fq2l$2vi$1@fred.mathworks.com>
Reply-To: "Prabhat Shankar" <prabhat4686@yahoo.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1213973222 17944 172.30.248.37 (20 Jun 2008 14:47:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 20 Jun 2008 14:47:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1421660
Xref: news.mathworks.com comp.soft-sys.matlab:474989


"Anthony " <anthony.campos@baesystems.com> wrote in message
<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?

Hi Anthony
You can use function num2str for this purpose. For example :

x = 1 + 2 * i
fprintf ( 1, 'X = %s\n', num2str ( x ) );

This works for both +ve as well as -ve imaginary parts and
you won't have to do other tricks as mentioned in the other
solutions.
Hope that helps.

Prabhat