I've noticed lately that I've been getting a lot of search hits here and at the home page about plotting phase portraits (in MATLAB).
In the past, I have advised people to look into trying pplane (and dfield). pplane is a great program that makes it very easy to tackle nonlinear time-invariant differential equations of two states. Not only can you generate the field, but you can plot a phase portrait with trajectories of your choice and can then plot each of those state trajectories against time to see how the system actually evolves in finite time. It's a nice front-end to lots of other MATLAB utilities that makes it easy to get through your first course in nonlinear systems.
However, there is a lot of value to try doing all of this yourself. You'll learn a lot by opening up simulink and dragging an integrator in (you can use one integrator to integrate your entire state matrix -- an xdot vector goes in and an x vector comes out). Use the output of the integrator as your actual states. Setup your differential equations in simulink using those states and running the resulting expressions for each of the differentials into the input of the integrator. Then place a scope on one of your state vectors (on the output of the integrator) and watch how it evolves in time. Simulink will solve the differential equation for you. (NOTE: You load your initial condition into the integrator)
Doing this in simulink really gives you an intuitive feel for how MATLAB solves these equations numerically. In the end, it's a discretization -- the idea is to use the xdot vector to predict the NEXT x vector at the next sampling time. Simulink will pick its sampling time automatically by default, but you can change this too.
Once you've done it in simulink, you can see how you can add time-variance into the expression.
After all of this, it's really worth looking into doing it manually with ode45 (or one of the many other solvers). Type "help ode45" for details, but it's very simple.
Pass it an initial condition, a time span, and a function that represents the differential equation and it will give you a trajectory. You can even pass it output functions so it will automatically output the trajectories it generates each (or each 10th, for example) iteration. It's a nice tool.
When dealing with very high order systems (say a few thousand states), I find ode45 to be a great solver providing an easy way to simulate the system.
Start with pplane to get your bearings. Then work with simulink to make sure you understand what's going on. Then graduate to actually using the ode tools. You'll be better for it.
2 comments:
hi, kindly tell me that how can i plot 4th order equation (havind 4 states) in pplane environment
The pplane tool is used for visualizing planar phase portraits (i.e., two state variables). If your 4th-order differential equation evolves along a 2nd-order surface, you could transform your 4th-order ODE into a 2nd-order ODE and use pplane to visualize it.
Otherwise, you will need to generate the appropriate visualization manually.
Post a Comment