I'm quite new to ODE45, and have a form of an equation I wish to solve with some unusual features - C is a function of r. I want to evaluate it on the interval [RN RO] where RN is not equal to zero. It is a second order equation and I have reduced it into a series of first order equations so ODE45 can handle it. The X vector for these equations is

X(1) = CX(2) = Z = C'

Now, I can convert this to two order ODES. In this case, J, H and K are known constants and I get.....

dX(1) = X(2)

dX(2) = (J*X(1) - (2/r)*(X(1) + K)*X(2))/(X(1) + K)

I know also that

C(RN) = 0 so then X(1) @ RN = 0Z(RN) = 0 so then X(2) @ RN = 0

However, I'm confused about how to implement this for 2 reasons; (1) my equation dX(2) has an r term in it, which C is a function of; how do I make MATLAB recognise this?

and (2) My initial conditions (or in this case, an analog of initial conditions as r refers to radius rather than time) are not zero; all values of C from 0 to RN are already zero, and I want to evaluate the function between the limits [RN RO].

Does anyone know if this is possible, and how one would implement this? I'd be most grateful for answers, as my knowledge is limited here and it seems an unusual form so I can't find examples to work with...