From: Sean Flynn on 5 Aug 2010 19:19 Hi, I am using ode45 to solve an initial value problem. I am trying to solve the ordinary differential equation diff_eq defined below, for p as a function of u. My tspan is from -1.828427124746190 to 3.828427124746190. My initial condition is p0 = -1.828427124746190 - value value can take on any positive value. When I try value = 0.8 ==> initial condition is -2.628427124746191. I get a solution curve up to a certain point, and then it returns NaN. I'm wondering exatly why is it returning NaN. Does that mean that there is no solution there? Thank you very much in advance for you help. All the best, Sean function [dp] = diff_eq(u,p,params) mean_x = params(1,1); var_x = params(2,1); var_z = params(6,1); mean_u = params(7,1); var_u = params(8,1); b = var_z/(var_u); eval_pt = p-b*(u-mean_u); density = normpdf(eval_pt,mean_x,sqrt(var_x)); cum_density = normcdf(eval_pt,mean_x,sqrt(var_x)); dp = b* density*(u-p)/(density*(u-p)-cum_density);
From: Steven_Lord on 6 Aug 2010 10:04 "Sean Flynn" <smflynn26(a)yahoo.com> wrote in message news:i3fgtb$gjm$1(a)fred.mathworks.com... > Hi, > > I am using ode45 to solve an initial value problem. I am trying to solve > the ordinary differential equation diff_eq defined below, for p as a > function of u. My tspan is from -1.828427124746190 to 3.828427124746190. > My initial condition is p0 = -1.828427124746190 - value > value can take on any positive value. When I try value = 0.8 ==> initial > condition is -2.628427124746191. I get a solution curve up to a certain > point, and then it returns NaN. I'm wondering exatly why is it returning > NaN. Does that mean that there is no solution there? Thank you very much > in advance for you help. It likely means that the value of dp in your function has become Inf or NaN at some point. Set an error breakpoint that looks for Inf or NaN values then run your function. You can then figure out for what values of u and p your function is being called that result in the nonfinite value. http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/brqxeeu-175.html#brqxeeu-242 -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: vector with elements 0 and 1 Next: Initial Value Problem - ode45 returns NaN |