Look at your rk4 code. You return two variables, T and Y. The T is clearly a vector since it is assigned as
which is going to give a vector result unless h is negative (in which case it would be empty) or unless h exceeds +8 (in which case it would be the scalar [2]).
The rest of what you calculate in rc4 is a waste of time, as you never use the second output of rc4 in you calling code.
So you have a vector being returned from rc4, and you attempt to assign that to Y(j+1) . but j is a scalar so Y(j+1) designates a scalar location. You cannot store a vector of some 801 elements (T) inside a scalar.
You should also be paying attention to the fact that your rc4 implementation ignores its first 3 parameters. Why are you even bothering to pass them in if they are going to be ignored?
Best Answer