Assume that we have the differential equation of a mass-spring-damper model as follows: $$ m\frac{d^2y}{dt^2}+c\frac{dy}{dt}+ky(t)=F(t) $$

How it could be implemented in MATLAB to do the following steps:

First, convert the differential equation to a difference equation.

Second, finding the discrete-time transfer function of it.

Third, finding the regression equation of this system.

Finally deriving Recursive Least Squares (RLS) and Ordinary Least Squares (OLS) to estimate the free parameters of the system ($m$,$c$, and $k$).

More information on this system is available at Mass-Spring-Damper System Excited by Force F(t)

Any help is greatly appreciated

  • 1
    $\begingroup$ This sounds like homework to me. What have you tried? What are you having trouble with? $\endgroup$
    – Chuck
    Jan 17, 2016 at 1:29
  • $\begingroup$ Do you need to follow this approach or can you do it differently? Is it a theoretical question or do you want to identify the parameters with a physical set-up? $\endgroup$
    – Karlo
    Feb 16, 2016 at 9:36

1 Answer 1


Matlab with some tips

A good method is using the Billinear transform (Tustin's method).

s = tf('s')
Hc = 1/(m*s^2+c*s+k)   % Tf continuous-time

Observation.: First declare your variables: m, c and k.

Matlab provides some functions that help with the transformation. The function c2d().

Ts = 0.1;
Hd = c2d(Hc,Ts,'tustin')

where Ts is the sample time.

  • To find the difference equation, apply the inverse Z transform after using tusting method in your equation. Remember that you need to use Laplace transform first!

$\hspace{2.5em}$ $Y(s)\big(ms^{2}+cs+k\big) = \mathcal{L}\{F(t)\}$

  • You can find good info about OLS here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.