Hello Iounis,
I gather that you want to compare the system transfer function with the transfer function generated from input and output signals.
To compare the transfer function (H(s)) of a system with the transfer function derived from input ((x_{inp})) and output signals ((x_{out})), you can use the Fourier Transform to analyze the frequency domain behavior of both the signals and the given (H(s)). The Fourier Transform is suitable for this task because it allows us to examine how different frequencies are altered by the system, which is essentially what a transfer function represents.
Please refer to the below workflow to perform the comparison:
- First, compute the Fourier Transform of both input and output signals to move from time domain to frequency domain. Then, calculate the ratio of the output to input in the frequency domain, which serves as an experimental transfer function.
- Compute the given (H(s)) over a frequency range and evaluate it over a range of frequencies to compare it with the experimental results from the Fourier Transform.
- Compare the experimental transfer function (H_{exp}) derived from your signals with the given (H(s)) by plotting their magnitudes and phases over the frequency range.
Please refer to the below code snippet that illustrates this workflow:
x_inp = rand(100,1); % Random input signal, please insert your input here
x_out = rand(100,1); % Random output signal, please insert your input here
X_inp = fft(x_inp); % Fourier Transform of input signal
X_out = fft(x_out); % Fourier Transform of output signal
H_exp = X_out ./ X_inp; % Experimental transfer function
max_freq = 100; % Please use the required frequency here
% Define frequency vector (omega)
omega = linspace(0, max_freq, length(x_inp));
% Compute H(s) for the frequencies omega
Real_H = 23*cos(2*pi*omega) + 12*cos(5*pi*omega/10) + cos(2*pi*omega)/19 + 0.75*cos(5*pi*omega/10);
Imag_H = 11*sin(3*pi*omega) + 7*cos(9*pi*omega/2) + 10*sin(2*pi*omega)/2 + 1.25*sin(4*pi*omega/18);
H_given = Real_H + 1i*Imag_H;
% Magnitude comparison
figure;
subplot(2,1,1);
plot(omega, abs(H_exp), 'b', omega, abs(H_given), 'r--');
xlabel('Frequency (rad/s)');
ylabel('Magnitude');
legend('Experimental', 'Given');
% Phase comparison
subplot(2,1,2);
plot(omega, angle(H_exp), 'b', omega, angle(H_given), 'r--');
xlabel('Frequency (rad/s)');
ylabel('Phase (radians)');
legend('Experimental', 'Given');
Hope it helps!