Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!news-2.dfn.de!news.dfn.de!newsfeed.straub-nv.de!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: dpb <none@non.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: read
Date: Mon, 17 Aug 2009 08:51:47 -0500
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <h6bnh1$8st$2@news.eternal-september.org>
References: <h6acsh$2c$1@fred.mathworks.com> <h6adn3$mg7$1@news.eternal-september.org> <5778a733-8101-4b16-87c3-08299f831834@n11g2000yqb.googlegroups.com> <h6ah43$pus$1@fred.mathworks.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.eternal-september.org U2FsdGVkX18esCq/JFD8UaPXde8XdHLNRTbZ4NDjN3H9h8yE9/hzSNFPxrJkhkVaqjBUyVDXeV5pGhWUwbIcCoKSFveiZKD5lquvp+3qVqZoY7BY1C5APK1uVRWoUXgQk4dLcX2GV7U=
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Mon, 17 Aug 2009 13:55:46 +0000 (UTC)
In-Reply-To: <h6ah43$pus$1@fred.mathworks.com>
X-Auth-Sender: U2FsdGVkX19u9a7G+0yqaCy+J5c2hoGgOvH33u+DgUM=
Cancel-Lock: sha1:6y/IFhMRDMs2m/d5MSh8+SkfHIk=
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
Xref: news.mathworks.com comp.soft-sys.matlab:563962


nachiketha Kukkady wrote:
...
> what i need is get some required lines like 20th, 34th,56th and so on
> and finally do some processings with it.... i don't want to use the
> loop here...
> So what can i do now????


 >> x=rand(4); % some sample data
x =
     0.9501    0.8913    0.8214    0.9218
     0.2311    0.7621    0.4447    0.7382
     0.6068    0.4565    0.6154    0.1763
     0.4860    0.0185    0.7919    0.4057
 >> idx=[1,3]
idx =
      1     3
 >> y = x(idx,:)
y =
     0.9501    0.8913    0.8214    0.9218
     0.6068    0.4565    0.6154    0.1763
 >> notx=[2 4]
notx =
      2     4
 >> x(notx,:) = []
x =
     0.9501    0.8913    0.8214    0.9218
     0.6068    0.4565    0.6154    0.1763
 >>

Read up on colon operator and logical indexing...

--