Path: news.mathworks.com!not-for-mail
From: "Jamie James" <jamie.james.nospam@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Complex structure to text file
Date: Wed, 28 Nov 2007 09:45:41 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 32
Message-ID: <fijdc4$nr7$1@fred.mathworks.com>
References: <f9fq2l$2vi$1@fred.mathworks.com> <muyhcj78osx.fsf@G99-Boettcher.llan.ll.mit.edu>
Reply-To: "Jamie James" <jamie.james.nospam@mathworks.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1196243141 24423 172.30.248.38 (28 Nov 2007 09:45:41 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 28 Nov 2007 09:45:41 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1197369
Xref: news.mathworks.com comp.soft-sys.matlab:439758


Peter Boettcher <boettcher@ll.mit.edu> wrote in message 
<muyhcj78osx.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "Jamie James" <jamie.james.nospam@mathworks.com> writes:
> 
> > Hello Rick,
> >
> > I have been loking at you solution for writing complex 
> > data in a file using fprintf. That will work well, if 
your 
> > imaginary number is always positive.
> >
> > I am in the same situation, but my imaginary number 
might 
> > change a sign, then using the solution posted on web, 
e.g.,
> > gives me a+-jb, what I will be looking for a-jb
> >
> > Could you please help, to write complex structure in a 
> > file for negative imaginary number.
> 
> fprintf('%f%+fi\n', real(x), imag(x));
> 
> The trick is the %+f flag, which says print the sign of 
the variable,
> even if it's plus.
> 
> -Peter
***********************************************************
Peter,

That works, great. Thanks for the help.
JamieJames