Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
find position in a vector

Subject: find position in a vector

From: Antonio Valentine

Date: 22 Jul, 2013 15:56:10

Message: 1 of 4

Hello there,

I have a vector of



>> x = [200;500;400;480;900;560;820;0]

I want to have a vector Y that x > 200. So I wrote

>> y = x(x > x(1))

So I get "500 400 480 900 560 820"

It returns me a value. But I need to know a position e.g.

I need the return of y = [2 3 4 5 6] not y = [ 500 400 480 900 560 820];

How should I do in this case? It is quite simple but I really have no idea.

Thank you

AV.

Subject: find position in a vector

From: Chris

Date: 22 Jul, 2013 16:42:10

Message: 2 of 4

Try this:

x.*(x>200)

Subject: find position in a vector

From: dpb

Date: 22 Jul, 2013 16:50:35

Message: 3 of 4

On 7/22/2013 10:56 AM, Antonio Valentine wrote:
...

[given]

>>> x = [200;500;400;480;900;560;820;0]
>
> I want to have a vector Y that x > 200. So I wrote
>
>>> y = x(x > x(1))
>
> So I get "500 400 480 900 560 820"
>
> It returns me a value. But I need to know a position e.g.
>
> I need the return of y = [2 3 4 5 6] not y = [ 500 400 480 900 560 820];
>
> How should I do in this case? It is quite simple but I really have no idea.

doc find

--

Subject: find position in a vector

From: dpb

Date: 22 Jul, 2013 16:52:31

Message: 4 of 4

On 7/22/2013 10:56 AM, Antonio Valentine wrote:
...

[given]

>>> x = [200;500;400;480;900;560;820;0]
>
> I want to have a vector Y that x > 200. So I wrote
>
>>> y = x(x > x(1))
>
> So I get "500 400 480 900 560 820"
>
> It returns me a value. But I need to know a position e.g.
>
> I need the return of y = [2 3 4 5 6] not y = [ 500 400 480 900 560 820];
>
> How should I do in this case? It is quite simple but I really have no idea.

doc find

--

Tags for this Thread

No tags are associated with this thread.

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.

Contact us