Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to read and write a portion of a file
Date: Sun, 16 Nov 2008 18:52:02 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 14
Message-ID: <gfpq4i$mte$1@fred.mathworks.com>
References: <gfcj8m$ksi$1@fred.mathworks.com> <gfo3f5$a94$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 1226861522 23470 172.30.248.37 (16 Nov 2008 18:52:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 16 Nov 2008 18:52:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:501100


Hi Zahra,
simply speaking, you want to copy a part of the file to a new file, right? 
Have you thought of

1. reading in the whole file with fread into a character array (some 10000 lines does not sound _too_ large to me)
2. find the indices for [char(10), 'Run 1000' char(13)] and [char(10), 'Run 2000' char(13)] (adjust for your exact format, line break characters, and boundary numbers)
3. copy the characters of interest by the help of those indices and write them to the new file

Doing so would avoid any for loop and text conversion.

You could gain speed and make this suitable for really large files by analyzing only smaller portions of the file, guessing where your lines of interest are and iterating towards them (which would use a while loop most probably and fseek to navigate through the file).
Maybe this is a viable solution.
Hth
Andres