Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to extract data out of a text file
Date: Mon, 13 Oct 2008 20:17:01 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 33
Message-ID: <gd0abt$1ro$1@fred.mathworks.com>
References: <gd08nd$dsr$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1223929021 1912 172.30.248.37 (13 Oct 2008 20:17:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 13 Oct 2008 20:17:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:494954


"Diego Zegarra" <diegozbb@gmail.com> wrote in message <gd08nd$dsr$1@fred.mathworks.com>...
> Hey guys, 
> I have .txt files that have the following structure and they all are different.
> 
> 12
> 120
> 
> 81 79 85 97 91 75 60 98 79 56 91 82
> ...
> ..
> .
> 74 74 64 86 90 59 98 74 53 56 81 58 
> 50 90 76 68 53 57 60 73 72 62 99 55
> 
> 69 74 75 62 76 55 67 55 78 96 69 79 69 97 53 59 72 ... 56
> ...
> ..
> .
> 89 78 91 72 59 52 92 96 95 95 74 98 99 68 55 69 66 ... 76
> 
> So let me explain what this means. First the 12 and 120 means 12 machines (m) and 120 jobs (n). I want to be able to save this as a variable.
> 
> Then the next block shows a number of jobs times number of machines matrix which I also want to save as a different variable.
> 
> After that there are m blocks of data (12 in this case) with a matrix of nxn. I want to be able to save each of these blocks in a variable each.
> 
> All my files will have a different number of machines and jobs so I want MATLAB to be able to read this automatically.

Maybe txt2mat (file exchange) can help you with this; you could simply type
A = txt2mat('C:\filename.txt');
to get in all the data into one larger matrix (padded with NaNs where no data is available) and then examine this matrix to find out the indices of interest.
Hth,
Andres