Hi, I have a system of ODEs that I can solve using ode23. To solve I do:
[t, S] = ode23(@odefunc,tSpan,S0)
and then what I am really interested in is a variable:
D(t) = 2*pi*(S(1)(t) + S(2)(t) + S(3)(t) + ...)
and then I plot D(t) vs t.
Doing it this way, however, I am forced to store all S(1)(t), all S(2)(t), etc. when I really only need their sum for each time. This takes a lot of memory since I have 280k*3 equations. How can I go about just calculating D at each step and saving that in an array to then plot D(t) vs t.