Prev: Nonlinear Constraint in GA
Next: Indexing array within ode45 solver - Equations of motion for pendulum with moving support
From: Tom Lintern on 7 Jul 2010 21:55 Hi, I currently have the eqtuations of motion for a pendlum with a moving support. The x co-ord of the origin moves along some known path, prescribed in the main file before the solver is called. i.e x = [x(t=0),x(t+dt),x(t+2dt).....] The paramaters I am solving for are the angle of the pendulum (y(1)) and the angular velocity (y(2)) and an example of the form that the equations of motion are in is shown below: -(l*m*cos(y(1))* x'' +phi*y(2)+l*m+l*m*g)*sin(y(1)))/(l^2*m) The problem occurs when I have to access x''. I can differentiate x to get another array and it is then padded to be the same length as x. I therefore need to access x'' at the appropriate time index depending on where in the solver I am. However the solver does not increment t in multiples of dt. Does anyone know how I can get around this? Possibly interpolate x'' within each function call? Thanks very much!!
From: Steven Lord on 8 Jul 2010 14:34
"Tom Lintern" <tlin067(a)aucklanduni.ac.nz> wrote in message news:i13b6a$fhv$1(a)fred.mathworks.com... > Hi, > > I currently have the eqtuations of motion for a pendlum with a moving > support. The x co-ord of the origin moves along some known path, > prescribed in the main file before the solver is called. i.e x = > [x(t=0),x(t+dt),x(t+2dt).....] > > The paramaters I am solving for are the angle of the pendulum (y(1)) and > the angular velocity (y(2)) and an example of the form that the equations > of motion are in is shown below: > > -(l*m*cos(y(1))* x'' +phi*y(2)+l*m+l*m*g)*sin(y(1)))/(l^2*m) > > The problem occurs when I have to access x''. I can differentiate x to get > another array and it is then padded to be the same length as x. I > therefore need to access x'' at the appropriate time index depending on > where in the solver I am. However the solver does not increment t in > multiples of dt. > > Does anyone know how I can get around this? Possibly interpolate x'' > within each function call? I'm not entirely certain what you're trying to do; perhaps if you posted a small sample of your code (say your ODE45 call and your ODE function) it might be easier to understand. If I _had_ to guess I'd say you've probably forgotten to (or didn't know you needed to) convert your higher-order ODE into a system of first-order ODEs like this example demonstrates: http://www.mathworks.com/access/helpdesk/help/techdoc/math/f1-662913.html#brfharp-1 -- 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 |