How can I divide a line of code in the ODE solver into two lines of code?

Hello guys,
This is the first question Im asking on the forum, so forgive me if I'm a bit awkward in formulating the question. Please tell me if I need to add/change anything :)
I want to solve a large set of equations in the ODE 15s solver. This is an example of one line:
dy(212) = 1./tau.*(ggluta_bound.*Sg(:,212).*(Egluta-V(212))+
(gGABA_rest+(gGABA_bound-gGABA_rest).*1.*(SG2(39)))
.*(EGABAp-V(212))+gK.*(EK-V(212))+delta.*((V(211)-V(212))+(V(229)-V(212))));
I actually want to write this line like this:
dy(212) = 1./tau.*(ggluta_bound.*Sg(:,212).*(Egluta-V(212))+
gGABA(212)
.*(EGABAp-V(212))+gK.*(EK-V(212))+delta.*((V(211)-V(212))+(V(229)-V(212))));
with an additional line:
gGABA(212)=gGABA_rest+(gGABA_bound-gGABA_rest).*1.*(SG2(39));
But somehow this doesnt work in the ODE solver. Is there anyway around this? It would make the code a bit more readable.
Thanks!
Sanne
.....................
PS: SG2's derivative (dSG2) is also computed in the solver.

 Accepted Answer

OK I think I figured it out:
Ive rearranged the order of the equations in the solver and it seems to work now!

More Answers (0)

Tags

Asked:

on 4 Jan 2015

Answered:

on 5 Jan 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!