Hi everyone! I need to write a function for ode45 solver, but the results I'm getting are wrong. What i need to get is a system of ODEs. To do so i prepared something like this:
function dndt = fun(t,n)global v%v is defined in another file
dndt = zeros(numel(v),1);for i = 1 : numel(v) - 1 dndt(i) = sum(n(i : numel(v))) * v(i+1) - v(i) * n(i);endend
Now, my question is: sum(n(i : numel(v))) should be the summation of n(k) with k going from i to number of intervals. Is it correct to write it like that? Or should I introduce another for loop to solve that summation? Thanks!
Best Answer