solve a second order Differential equation with a forcing function containing multiple harmonics

8 views (last 30 days)
Dear all,
I need to solve a second order ODE shm by numerical integration. It contains a forcing function with multiple harmonics of cosine function.Can anyone suggest an appropriate numerical method and how to implement it in matlab?
Regards.

Accepted Answer

Jarrod Rivituso
Jarrod Rivituso on 18 Apr 2011
I believe you can do this with any of the ode solvers.
One thing to note is that you need to convert the second order ODE to a system of two first order ODEs and explicitly solve for the derivative terms. For instance, the equation
a*x'' + b*x' + c*x = cos(3*pi*t) + cos(4*pi*t)
would become the two equations
x(2)' = (1/a) - b*x(2) - c*x(1) + cos(3*pi*t) + cos(4*pi*t) x(1)' = x(2)
Then, you can easily write the derivative function that the ODE solvers require:
function dx = derivs(t,x)
a = 1;
b = 1;
c = 1;
dx = zeros(2,1);
dx(1) = x(2);
dx(2) = (1/a) - b*x(2) - c*x(1) + cos(3*pi*t) + cos(4*pi*t)
  4 Comments
Shravan Chandrasekaran
Shravan Chandrasekaran on 20 Apr 2011
Hi Jarrod, It was the forcing function intensity. I have a periodic response which is also multi harmonic but it keeps drifting away from time axis with increase in time. Any suggestions ?
Jarrod Rivituso
Jarrod Rivituso on 20 Apr 2011
You'd have to tell me what the equation is. I'd assume it has something to do with the dynamics of the ODEs.
You could try changing the phase of the forcing functions to see if that changes anything. I've seen similar "drifts" before that had to do with that.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!