You would be best served to learn to use the debugger. But I can see what happens.
At the first iteration, i = 1. And all of your variables are initially scalars, thus L, T, R, and C.
But inside the while loop, you add new elements to those variables, that were once scalars. But you ONLY append a new element under a specific condition. Thus, we see:
if r2 * prop_sum <= props(1)
What happens if that test fails?
If it fails, then L and C and P and R are NOT expanded.
But then you increment i. And you ALWAYS increment i on EVERY iteration. So what happens after the first iteration? i is now 2. But if that test failed, then those variables are still scalars. And on the second iteration, you try to access L(2), and C(2), and R(2).
Worse, you will continue to have this problem in the future for later iterations, every time that test fails. And since the test is dependent on a random value in r2, it may fail often enough.
So I have no idea what is your goal in writing this code. But it has a bug built into it. You need to rethink what you are doing.