On 5/30/2011 2:13 PM, AJP wrote:
> Say I have a vector of data x and a function f(x).
>
> Now say I want to evaluate f(x) only for x>2, so I do:
>
> ind=x>2;
> y=f(x(ind));
>
> Now say I want to find y>5;
>
> ind2=y>5;
>
> Now how can I use this information to get the x values corresponding to the y>5 values,
> WITHOUT using this crude method where I create an intermediate variable:
>
> x_intermediate = x(ind1); % I want to avoid creating this
>
> x_answer = x_intermediate(ind2);
In matlab, such indexing type operations need to be applied to an
actual variable
so, one can't write sin(x)(4) for example, but must make a temporary
variable
v=sin(x)
v(4)
I think octave (Matlab clone) might do what you are looking for,
I know it does support sin(x)(4) type operations.
It would be nice if one can do that in Matlab, but I am sure there
is a good technical reason why it is not implemented in Matlab.
Nasser
