Assume that I want to identify a transfer function from frequency data. Assume that I have a transfer function step response which look like this:
By experience, I would say that this step response is from a second order transfer function on standard form:
$$G(s) = \frac{Y(s)}{U(s)} =\frac{b_0}{a_0s^2 + a_1s + 1 }$$
So I want to find $a_0, a_1, b_0$. Well! I can assume that
$$Y(s) = G(s)U(s)\\ Y(s)(a_1s^2 + a_0s + 1) = b_0U(s) \\ Y(s)a_1s^2 +Y(s) a_0s + Y(s) = b_0U(s)$$
What I know here is the system frequency $s$ and the amplitude input signal $U(s)$ and amplitude output signal $Y(s)$.
I can now use Least Square(LS) to estimate a transfer function by using this:
$$\begin{bmatrix} Y(s_0)\\ Y(s_1)\\ Y(s_2)\\ Y(s_3)\\ \vdots \\ Y(s_n) \end{bmatrix} = \begin{bmatrix} -Y(s_0)s_0^2 & Y(s_0)s_0 & U(s_0) \\ -Y(s_1)s_1^2 & Y(s_1)s_1 & U(s_1) \\ -Y(s_2)s_2^2 & Y(s_2)s_2 & U(s_2) \\ -Y(s_3)s_3^2 & Y(s_3)s_3 & U(s_3) \\ \vdots & \vdots & \vdots \\ -Y(s_n)s_n^2 & Y(s_n)s_n & U(s_n) \\ \end{bmatrix}\begin{bmatrix} a_1 \\ a_0 \\ b_0 \end{bmatrix}$$
Please. Correct me if I'm wrong to this.
Question:
Now I need to find $s$ and $Y(s), U(s)$. One thing is to look at measured data of input $u$ and output $y$.
But how can I do this in MATLAB/Octave? Is there any algorithm or function for this. To find the ampliude and the frequency from measured input and output. The frequency would be the same, but not the amplitude.


Here is the answer.
I'm tired so I say that it cannot be done by estimate a transfer function from frequency response.
The only solution I have found is that if I rewrite this
$$\begin{bmatrix} Y(s_0)\\ Y(s_1)\\ Y(s_2)\\ Y(s_3)\\ \vdots \\ Y(s_n) \end{bmatrix} = \begin{bmatrix} -Y(s_0)s_0^2 & -Y(s_0)s_0 & U(s_0) \\ -Y(s_1)s_1^2 & -Y(s_1)s_1 & U(s_1) \\ -Y(s_2)s_2^2 & -Y(s_2)s_2 & U(s_2) \\ -Y(s_3)s_3^2 & -Y(s_3)s_3 & U(s_3) \\ \vdots & \vdots & \vdots \\ -Y(s_n)s_n^2 & -Y(s_n)s_n & U(s_n) \\ \end{bmatrix}\begin{bmatrix} a_1 \\ a_0 \\ b_0 \end{bmatrix}$$
Into difference equations - They are discrete ODE's:
$$\begin{bmatrix} y(k_0)\\ y(k_1)\\ y(k_2)\\ y(k_3)\\ \vdots \\ y(k_n) \end{bmatrix} = \begin{bmatrix} -y(k_0+2) & -y(k_0+1) & u(k_0) \\ -y(k_1+2) & -y(k_1+1) & u(k_1) \\ -y(k_1+2) & -y(k_2+1) & u(k_2) \\ -y(k_1+2) & -y(k_3+1) & u(k_3) \\ \vdots & \vdots & \vdots \\ -y(k_n+2) & -y(k_n+1) & u(k_n) \\ \end{bmatrix}\begin{bmatrix} a_1 \\ a_0 \\ b_0 \end{bmatrix}$$
Notice that $y(k+2)$ is acceleration, $y(k+1)$ is the derivative and $y(k)$ is the position.