Hi,
I have some problems getting the right results for an ODE with ode113. The right hand side has some sparse events. I startet with
[t, y] = ode113(@qd, [0 10], [0 0]);
but even with the version below I get a wrong answer. The integrator is not seeing all the events. Or what am I doing wrong.
Thank you,
Thomas
function goglobal A BA = 2;B= 0.4;t=linspace(0,10,1000);x = t;for i=1:1000 x(i) = f(t(i));endplot(t,x)axis([0 10 0 10])pause[t, y] = ode113(@qd, 0:0.01:10, [0 0]);plot(t,y(:,2),'-')grid onfunction qd=qd(t,q) qd=[q(2);f(t)];function f = f(t) global A B t = t-floor(t); f = 0; if t<B/2 f = A-A/(B/2)*t; end if t>1-B/2 f = (t-(1-B/2))*A/(B/2); end
Best Answer