Path: news.mathworks.com!not-for-mail
From: "Branko " <bogunovic@mbss.org>
Newsgroups: comp.soft-sys.matlab
Subject: Re: print a matrix ...
Date: Thu, 22 Oct 2009 07:48:03 +0000 (UTC)
Organization: National Institute of Biology
Lines: 25
Message-ID: <hbp2nj$bmq$1@fred.mathworks.com>
References: <hbopub$1m3$1@fred.mathworks.com>
Reply-To: "Branko " <bogunovic@mbss.org>
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 1256197683 11994 172.30.248.37 (22 Oct 2009 07:48:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 22 Oct 2009 07:48:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 237386
Xref: news.mathworks.com comp.soft-sys.matlab:579213


"Venkat " <vpisipati@yahoo.com> wrote in message <hbopub$1m3$1@fred.mathworks.com>...
> I am a matlab and programming novice.
> 
> Am trying to write a matrix(variable dimensions) to a text file. For instance
> 
> A = 
> 1.2   2.0   3.0
> 2.1   2.3   2.5
> 3.1   3.4   3.7
> 
> should be written with some format to a text file like:
> 
>    1.20       2.00      3.00
>    2.10       2.30      2.50
>    3.10       3.40      3.70
> 
> Can someone help. This seems such a silly question, but I need a quick soln to do some post processing. Thanks.
> 
> V


One possible solution:
infid=fopen('filename','wt');
fprintf(infid,'%.2f %.2f %.2f\n',A');
fclose(infid)