daspk solver giving NaN for simple ODE

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

daspk solver giving NaN for simple ODE

Master
I have written a code to solve a simple ODE uprime=0 and u_0=23. The solution
should obviously be u=23 at each timestep.

The code is as given:

u_0=23;
udot_0=0;
u=zeros(50,1);
udot=zeros(50,1);
for i=1:50
        t(i)=(i-1)*2;
end
t_crit=100;
daspk_options("compute consistent initial condition",0);
daspk_options("algebraic variables",0);
[u, udot, istate, msg] = daspk(@test, u_0, udot_0, t, t_crit)
*
And the function to evaluate residuals is as : *
function res=test(u,udot,t)
        res(1)=udot;
endfunction

But the output of the code is :
u=
23
NaN
NaN
.
.
.
. and
udot=
0
NaN
NaN
NaN
.
.
.


I am new to using daspk, and unable point out the error. However, if i
replace daspk with dassl, it computes the correct solution.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html