I understand you are trying to solve system of ODEs using RK iteration. The error occurred in the iteration due to following reasons-
- Inside your ‘RK2’ function there is no defined value of ‘xn’.
- Inside ‘RK2’ matlabFunction function converts Symbolic expression to function handle. So, the first ODE becomes 3 Variable function.
- In the following code
The code will error out because the function handle takes 3 inputs and, in the statement, only two inputs are present.
After Resolving these issues, the code should work.