Home > Archive > Matlab > March 2007 > find function
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Hi,
Is it possible that the find function returns the value of the cell
and NOT the indice of the cell?
For example:
X = [1 0 4 -3 0 0 0 8 6];
A = find(X > 2)
It gives me A = 3 8 9 , I don't want these values. I want is A = 1 4
8 6
Is it possible?
Thanks,
Le
| |
|
| Le wrote:
>
>
> Hi,
>
> Is it possible that the find function returns the value of the cell
> and NOT the indice of the cell?
>
> For example:
>
> X = [1 0 4 -3 0 0 0 8 6];
>
> A = find(X > 2)
>
> It gives me A = 3 8 9 , I don't want these values. I want is A = 1
> 4
> 8 6
>
> Is it possible?
>
> Thanks,
>
> Le
disp(X(A));
| |
| Trevor 2007-03-30, 7:11 pm |
| You don't need the "find" function. You can use logical indexing,
which makes things faster:
X(X>2)
| |
|
| Trevor wrote:
>
>
> You don't need the "find" function. You can use logical indexing,
> which makes things faster:
>
> X(X>2)
Thanks,
Le
| |
| Dan Hensley 2007-03-30, 7:11 pm |
| On Fri, 30 Mar 2007 14:39:26 -0500, Le wrote:
> Hi,
>
> Is it possible that the find function returns the value of the cell and
> NOT the indice of the cell?
>
> For example:
>
> X = [1 0 4 -3 0 0 0 8 6];
>
> A = find(X > 2)
>
> It gives me A = 3 8 9 , I don't want these values. I want is A = 1 4 8 6
Uh, since 1 is less than 2, how do you expect find to return the index to
it since you're asking for X>2? And find returns indices, not the values.
Are you sure you don't want
A=X(X>0);
Dan
|
|
|
|
|