Reputation: 9040
I'm new to Matlab, and I'm trying to solve the differential equation y'=-y/n for a constant n. I define the function in a script like this:
function dv = lc(v1)
dv = -v1/(0.0000047*0.000001);
And then try and solve it like this:
[t,v] = ode23('lc',[0 5],1)
But the operation never finishes executing. It just eats up my RAM and says "Busy" in the corner, until I press ctrl+c to terminate it. What am I doing wrong here?
Upvotes: 0
Views: 78
Reputation: 7308
You're a victim of underflow. What happens is that there is not an infinite number of floating point numbers (see Is floating point math broken?), so the results are not fully precise. When the numbers are small enough there is the possibility of the number being treated as 0
by the computer. The process that matlab uses for ode23
is based on finite differencing, which involves division. Considering the underflow error, there either will be a division by 0
issue, or possible overflow with an incredibly small divisor trending the result toward infinity and not fulfilling the conditions for solution.
Upvotes: 1