Azzera filtri
Azzera filtri

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

7 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Jarrod Rivituso
Jarrod Rivituso il 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 Commenti
Shravan Chandrasekaran
Shravan Chandrasekaran il 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 il 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by