Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: read ascii file
Date: Mon, 10 Nov 2008 12:08:02 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 32
Message-ID: <gf9872$b5u$1@fred.mathworks.com>
References: <gf909u$4n9$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1226318882 11454 172.30.248.38 (10 Nov 2008 12:08:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Nov 2008 12:08:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:499910


"DS" <null@null.com> wrote in message <gf909u$4n9$1@fred.mathworks.com>...
> [..] The files look something like this:
> 
> {{0,0,0, ... lots of numbers ... ,0,0,0},{0,0,0, ... lots of numbers ... ,0,0,0}, etc }
> 
> It's a square matrix all on a single line, comma delimited, with each row and the entire matrix enclosed in curly braces.
[..]
.
.
Hi,
if the curly braces are your only char data, i.e. inside the braces there are just numbers, you could do the trick with txt2mat (file exchange):
.
A = txt2mat('file.txt',...
    'ReplaceExpr',{{'},{',char([13 10])}},...
    'ReplaceChar',{'{}, '});
.
I assumed that 
- you don't know the size of the matrix before (which would help to speed things up)
- the rows are reliably separated by '},{'
.
I checked this on a sample file containing the only line
{{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}
Of course,
.
B = txt2mat('file.txt','ReplaceChar',{'{}, '});
n = sqrt(numel(B));
B = reshape(B,n,n).';
.
would work as well.
Ok, this is kind of hacking the braces out, but it should be quite fast.
Hth
Andres