Hi there, I'm trying to program a piecewise geometric function into matlab:

I have written the code as follows. If anybody can explain why the output (Sij) always equals 1 when I run this it would be helpful. The input "rrup" is just a bunch of random distance values ranging from 0 to 1000 (km).

`decay0 = 1.0;decay1 = 0.0;decay2 = 2.22;r0 = 50;r1 = 50;r2 = 150;r = rrup;for i = 1:length(r)if r(i)<r0 Sij = (r0/r(i)).^decay0elseif r1<=r(i)<=r2 Sij=(r1/r(i)).^decay1elseif r(i)>r2 Sij =(r2/r(i)).^decay2endend`

## Best Answer