Assume that we got a sine wave function
$$u(t) = A\sin(2\pi \omega(t)t)$$
Where the frequency $\omega(t)$ changes over time $t$ and $A$ is the amplitude.
Assume that we apply that $u(t)$ signal onto a transfer function $G(s)$ and we receive the output $y(t)$ in the time domain.
Then our goal is to create the bode plot diagram of $u(t)$ and $y(t)$.
I begin to do the FFT analysis.
$$F_u(t) = \mathcal{F.T}\bigl\{u(t)\bigr\}$$ $$F_y(t) = \mathcal{F.T}\bigl\{y(t)\bigr\}$$
Then I compute the ratio
$$H(t) = \frac{F_y(t)}{F_u(t)}$$
And then I cut everything in half
H = H(1:end/2)
w = w(1:end/2)
And then I plot the diagram where the y-axis is $20\log_{10}(| H |)$ and x-axis is w
Problem:
The problem is that the frequencies are not correct. To "shift" them to the correct values , I need to multiply with a constant a
:
w = w*a
Question:
How do I find that constant a
?
How to reproduce the issue:
close all
% Input and model
N = 30000;
t = linspace(0.0, 50, N);
w = linspace(0, 100, N);
u = 10*sin(2*pi*w.*t);
G = tf([3], [1 0.5 30]);
% Do frequency response
y = lsim(G, u, t);
close all
% Do FFT
fy = fft(y);
fu = fft(u);
H = fy./fu;
% Windowing - Half
H = H(1:end/2);
a = 1;
w = w(1:end/2)*a;
semilogx(w, 20*log10(abs(H)));
% Do bode without phase
bode(G);
Goal:
My goal/aim is to find the transfer function from measurement data. Estimation/identification.