Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!n11g2000yqb.googlegroups.com!not-for-mail
From: arun <aragorn168b@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: read
Date: Sun, 16 Aug 2009 19:33:25 -0700 (PDT)
Organization: http://groups.google.com
Lines: 50
Message-ID: <5778a733-8101-4b16-87c3-08299f831834@n11g2000yqb.googlegroups.com>
References: <h6acsh$2c$1@fred.mathworks.com> <h6adn3$mg7$1@news.eternal-september.org> 
	<h6aej0$h31$1@fred.mathworks.com>
NNTP-Posting-Host: 134.2.247.179
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1250476405 16853 127.0.0.1 (17 Aug 2009 02:33:25 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 17 Aug 2009 02:33:25 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: n11g2000yqb.googlegroups.com; posting-host=134.2.247.179; 
	posting-account=fyqXpgoAAABqt-0BifyaNxmZhzggFACu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; 
	rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:563818


On Aug 17, 4:17 am, "nachiketha Kukkady" <nachike...@in.com> wrote:
> dpb <n...@non.net> wrote in message <h6adn3$mg...@news.eternal-september.org>...
> > nachiketha Kukkady wrote:
> > > Hi.... I've a matlab file which contains few numbers(float) in about
> > > 75 lines... how do i read a individual line so that i can later
> > > process with these obtained numbers from some particular lines... i
> > > did try with fgetl but that gives only the first line.. or maybe i
> > > couldn't use it properly.... could somebody help me with this?? Thank
> > > you in advance....
>
> > Typically fgetl() is used in a loop.
>
> > Alternatively, w/ ML it may be simpler and just as quick to read the
> > whole array and then discard the portion you don't want.
>
> > --
>
> Thank you for that reply....
> Yeah i've already the whole page or file containing those numbers....
> my file is something like this.....
> 259.975 262.41
> 269.273 338.54
> 276.828 369.921
> 287.87 404.79
> 306.466 435.59
> 330.874 461.161
> 364.581 480.338.............
> i will be needing line 2, line 5 and so on for further calculations....
> As i said i've read the file using fread command.... but i don't know how exactly to remove the lines which i don't need.....
> thank you....  

You have the whole matrix here. you can just access the essential
entries then.

fn = <path to file>';
fid = fopen(fn, 'r');
%preallocate variable if you know the number of rows and columns
a = cell(6,2); % file contains first six lines of the sample you
posted above, with 2 columns.
i=1;
while ~feof(fid),
    a(i,:) = regexp(fgetl(fid),'\s', 'split'); %check for space.
    i = i + 1;
end
a= cellfun(@str2num, a, 'uni', false); % conver to double array.
fclose(fid);

best, arun.