I tried to add two differencial equations inside the dfun:
f2=??? ─────────↓
dfun=inline('[1,f2,dery(f(2))]','t','f','dery');
So the output for:
y0=initial value for y @ t=0
[t,y]=ode45(@(t,f) dfun(t,f,dery),t,[a,9999999,y0],...
odeset('Mass',[1 0 0;0 0 0;0 0 1]));
y(:,1)
Will be:
[a;a+t(1)-t(2);a+t(1)-t(3);a+t(1)-t(4);...];
Assumming the diference between the values t(n)-t(n+1)is constant for all the values on the vector t, we can choose the value for 'a' to be this same difference, so:
y(:,1)=[a;2a;3a;4a;...];
Using:
f2=f(1)/a
Will create the vector:
y(:,2)=[1;2;3;4;...];
That can be used as index numbers to get the scalar values from dery, my problem is the time vector have not constant differences, any idea?