# substitute

Hi,

I have the following line in my code with the intention to replace some elements in matrix ini1 with 1. However, the matrix stays the same. I wonder if there is anything wrong with my use of substute.

```ini1[.,q]=substute(ini1[.,q], inn[.,q]-0.01.<0, 1);
```

Thank you!

0

Your code should make some changes to ini1 if some of the elements in the qth column are less than 0.01. Here is a little self-contained example:

```inn = { 1, 0.001, 0, 2, 3 };
ini1 = 999*ones(rows(inn), 1);
q = 1;

print "before substute, ini1 = " ini1;
ini1[.,q]=substute(ini1[.,q], inn[.,q]-0.01.<0, 1);
print "after substute, ini1 = " ini1;
```

The output from this code is:

```before substute, ini1 =
999.00000
999.00000
999.00000
999.00000
999.00000
after substute, ini1 =
999.00000
1.0000000
1.0000000
999.00000
999.00000
```
0

I might try calculating the separate input on another line of code and then take a look at it to see if it has any 1's in it, like this:

```mask = (inn[.,q] - 0.01) .< 0;
```

If there are no 1's in the print out of mask then that is the problem.

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.