Thread Subject: Identify vector values >9 and subtract 10

Subject: Identify vector values >9 and subtract 10

From: Jack Daniels

Date: 22 Mar, 2010 04:19:04

Message: 1 of 3

Hi, just need a little help, I have no idea how to go about this.
If i was given an arbitrarily sized row vector, [1 18 4 5 9 14 11] in
this case. How would I identify all the values that are bigger than 9,
subtract 10 from them and add 1 onto the previous value in the row?
Thanks =)

Subject: Identify vector values >9 and subtract 10

From: us

Date: 22 Mar, 2010 08:21:04

Message: 2 of 3

"Jack Daniels" <maxxyA2_bmx@hotmail.com> wrote in message <ho6r3o$2bk$1@fred.mathworks.com>...
> Hi, just need a little help, I have no idea how to go about this.
> If i was given an arbitrarily sized row vector, [1 18 4 5 9 14 11] in
> this case. How would I identify all the values that are bigger than 9,
> subtract 10 from them and add 1 onto the previous value in the row?
> Thanks =)

one of the many solutions

     v=[1 18 4 5 9 14 11];
     ix=find(v>9);
     v(ix)=v(ix)-1;
     ix=ix-1;
     v(ix)=v(ix)+1;

us

Subject: Identify vector values >9 and subtract 10

From: Jack Daniels

Date: 22 Mar, 2010 09:12:05

Message: 3 of 3

"us " <us@neurol.unizh.ch> wrote in message <ho799g$5u4$1@fred.mathworks.com>...
> "Jack Daniels" <maxxyA2_bmx@hotmail.com> wrote in message <ho6r3o$2bk$1@fred.mathworks.com>...
> > Hi, just need a little help, I have no idea how to go about this.
> > If i was given an arbitrarily sized row vector, [1 18 4 5 9 14 11] in
> > this case. How would I identify all the values that are bigger than 9,
> > subtract 10 from them and add 1 onto the previous value in the row?
> > Thanks =)
>
> one of the many solutions
>
> v=[1 18 4 5 9 14 11];
> ix=find(v>9);
> v(ix)=v(ix)-1;
> ix=ix-1;
> v(ix)=v(ix)+1;
>
> us

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
code us 22 Mar, 2010 04:24:06
logical indexing us 22 Mar, 2010 04:24:06
linear indexing us 22 Mar, 2010 04:24:06
find us 22 Mar, 2010 04:24:06
rssFeed for this Thread

Contact us at files@mathworks.com