Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!o5g2000prh.googlegroups.com!not-for-mail
From: Nathan <ngreco32@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Take out index
Date: Wed, 24 Jun 2009 15:17:46 -0700 (PDT)
Organization: http://groups.google.com
Lines: 33
Message-ID: <c3448c04-efa4-463b-82c3-2e58518ba8d5@o5g2000prh.googlegroups.com>
References: <h1u7mu$kvs$1@fred.mathworks.com>
NNTP-Posting-Host: 198.206.219.34
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1245881867 11326 127.0.0.1 (24 Jun 2009 22:17:47 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 24 Jun 2009 22:17:47 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: o5g2000prh.googlegroups.com; posting-host=198.206.219.34; 
	posting-account=_KeVcAoAAAB7j3xn35ujaQ0BoQhuzwJP
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) 
	Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 wwwproxy-son-ca-02.ca.sandia.gov:80 (squid/2.5.STABLE14)
Xref: news.mathworks.com comp.soft-sys.matlab:550454


On Jun 24, 3:01 pm, "Diego Lass" <dlISC...@gmail.com> wrote:
> Hi
> For a problem,
> A = [ 1; 2; 3; 4; 5; 6; 7 ]
> A =
>   1
>   2
>   3
>   4
>   5
>   6
>   7
>
> I know that I want to add 2 to each element, expect for the entries 1:2:end
> i.e. I want to get a function f()
> B = f(A) such that
> B =
>   1
>   3
>   3
>   6
>   5
>   8
>   7
> what is the most efficient way to do this?  Remember add 2 is just a simple example, and the vector A might be really huge

What about
A(2:2:end) = A(2:2:end)+2;
B = A;

Simple enough?