# Replacement based on index

I have 2 vectors like this:

`rawRT` (nx1 double)

``````354
521
0
428
568
0
289
...
552
``````

`prob` (nx1 double)

``````.82
.75
.59
.27
.67
.36
...
.12
``````

Each value in `rawRT` corresponds to the value of the same order/location in `prob`. First, I want to apply some sort of transform to the values in `prob` if their corresponding values in `rawRT` is greater than zero.

I could do this: `index = rawRT>0`. Next, I find the values in `prob` that correspond to the ones in `rawRT` that are greater than 0: `prob_temp = prob(index)`. Next, I apply the transform: `prob_transform = [some function](prob_temp)`.

Now, what I am not sure how to do is to replace the values in `prob` with values from `prob_transform` in a way that the values that were NOT transformed in `prob` will remain intact. So in this example, `prob(1,1), prob(2,1)` will be replaced by values from `prob_transform` while `prob(3,1)` will remain the same as original.

Could anyone help?

### >Solution :

You just use the same index again for assignment

``````prob(index) = prob_transform;
``````

You could do this all in one hit

``````index = rawRT>0;
prob(index) = someFunction( prob(index) );
``````