Solving Second Order Differential Equation with Discrete Time Data

Given the Second Order Differential Equation:

$$m\ddot{x}+c\dot{x}+kx = \mathrm{F}_{external}^{}$$

where $$m, c, k$$ are constants and $$\mathrm{F}_{external}^{}$$ is buffer of external force taken at 48Hz.

Numeric solution is needed for $$x$$ in a form of a similar buffer.

Ty

EDIT: I posted this question in the wrong StackExchange. It was meant for the Math one not Mathematica. Its a c++ project. Sorry for everything and thanks for answers.

• may be you can try to fit the data collected to a function using Fourier analysis? Once you have the analytical model of the force this way, you can use DSolve. For multiple harmonics as input, you can solve the ODE solve for each one, and then add the solutions since the ode is linear. Nov 22 '21 at 11:14
• One easier possibility is to just use an Interpolation for the force Nov 22 '21 at 11:58
• Including code for a computable example would make it more likely that you would get help. Nov 22 '21 at 12:58
• You need to add some code to your post. What have you tried to far? Nov 22 '21 at 13:38

With DSolve:

eq1 = m x''[t] + c x'[t] + k x[t] == Fex*Cos[t]
DSolve[eq1, x[t], t]

With NDSolve you need to define the parameters first:

m = 1;
c = 0.01;
k = 1;
Fex = 1;
eq1 = m x''[t] + c x'[t] + k x[t] == Fex*Cos[t]
s = NDSolve[{eq1, x == 1, x' == 1}, x, {t, 0, 5}]
Plot[x[t] /. s, {t, 0, 5}]
• I recommend that you convert this to a comment. Nov 22 '21 at 16:50