How does drawode actually compute solution curves? After all, it is dangerous to run programs without having a solid idea how they work if you do, eventually you will make a serious mistake. Thinking about direction fields and their limitations leads us to two questions.
By changing the axes in slopefield, we might be able to zoom in and improve this estimate, but that can be an awkward way to obtain a highly accurate answer. From the direction field, we can guess that it is somewhere around 4.3. For example, we might want to find out the value of y in our solution above when x = 10. Even with two- or three-dimensional systems, visual techniques might fail us when we want to get very precise information. Indeed, most technology problems involve high-dimensional systems of ODEs, so that it is impossible to visualize their solutions. Unfortunately, such graphical techniques are limited to three dimensions at best. Pictures like these are very informative for understanding the behavior of the solutions to even very complicated differential equations. What does that suggest to us about this solution curve? When you run these commands, you will get a warning: MATLAB says it is "unable to meet integration tolerances without reducing the step size." In this case, the curve becomes so steep on the left side that the computer cannot accurately compute more points to plot in a reasonable time.
We've already seen in Assignment 2 how to use slopefield and drawode to get a picture of our solution.
One way we can get an idea of what the solutions to this (or any) differential equation look like is with a direction field. Thus we will need to use the numerical methods mentioned above. We have no symbolic methods for solving this equation. Convince yourself of this with a pencil and paper. The differential equation in (1) is not linear (because of the y 3), nor is it separable or exact. You'll need to use the events function to terminate integration when the conditions are met and then apply your perturbation as I've shown above.Consider the following initial value problem: (1) If you do want your perturbation occur when particular conditions are met (rather than at a particular time) then you'll need to use an event function (see this question, for example). You would have effectively produced a very stiff system. Second, inserting large discontinuities in your ODE can lead to less precision and longer computation times (especially with ode45 - ode15s might be a better option or at least make sure that your absolute and relative tolerances are suitable). First, if you want it to occur exactly at a particular time or when particular conditions are met, this can't be done from within the ODE function. What you don't want to try to do (but many attempt) is add your perturbation inside the integration function. The Matlab editor may complain about the array T and Y not being preallocated and/or growing, but it's fine in this case as they're growing in large chunks only a few times.
= % Remove first value as it will be same as last of previous run The way to do this is to integrate the system piecewise and append the resultant outputs from each run together: % t = 0 to t = 6