From: Stephen on 1 Mar 2010 21:10 I have written a program that simulates the trajectory of a probe entering earth's atmosphere. This trajectory is modeled by 6 differential equations. I am using ode45 to solve these equations. I would the solver to calculate a solution until the probe hits the ground, but the point at which it hits the ground is only know after the solution is displayed. I would like to create some sort of while loop that goes like this: while altitude >= 0 solve set of equations end display solution The problem is that the time at which the probe hits the ground is only known after the code has ran, so there is no way to know that at 1775 seconds into the simulation, the probe hits the ground. However, a time vector (independent variable) must first be defined before the system can be solved. I don't mind having an excess time vector and then for display purposes (equal size vectors) have the time vector chopped to the same size as the solution vector. The solution is working perfectly fine, but it takes so long for each step that any excess results would save time and eliminate bogus subterranean results. Anyone have any ideas on how this feat could be accomplsihed? Thanks.
From: Jan Simon on 2 Mar 2010 05:46 Dear Stephen! > I have written a program that simulates the trajectory of a probe entering earth's atmosphere. This trajectory is modeled by 6 differential equations. I am using ode45 to solve these equations. > > I would the solver to calculate a solution until the probe hits the ground, but the point at which it hits the ground is only know after the solution is displayed. Use the 'Events' property in OPTIONS, as suggested by: help ode45 Good luck, Jan
From: Steven Lord on 2 Mar 2010 09:49 "Stephen " <hphilli5(a)utk.edu> wrote in message news:hmhs21$a98$1(a)fred.mathworks.com... >I have written a program that simulates the trajectory of a probe entering >earth's atmosphere. This trajectory is modeled by 6 differential equations. >I am using ode45 to solve these equations. > I would the solver to calculate a solution until the probe hits the > ground, but the point at which it hits the ground is only know after the > solution is displayed. I would like to create some sort of while loop that > goes like this: > while altitude >= 0 > solve set of equations > end > display solution > > The problem is that the time at which the probe hits the ground is only > known after the code has ran, so there is no way to know that at 1775 > seconds into the simulation, the probe hits the ground. However, a time > vector (independent variable) must first be defined before the system can > be solved. I don't mind having an excess time vector and then for display > purposes (equal size vectors) have the time vector chopped to the same > size as the solution vector. The solution is working perfectly fine, but > it takes so long for each step that any excess results would save time and > eliminate bogus subterranean results. Anyone have any ideas on how this > feat could be accomplsihed? Thanks. Look at the BALLODE demo for an example that uses an Events function to answer exactly that question. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: My code: how to capture a 2D array and number of iteration Next: 2d gaussian fit |