results = load('N_006_fodem_best_003.mat');
results = results.Result;

fs = results.AcqSetup.Fs;
N = results.AcqSetup.nSamples;

freq = (0:N/2)'/N*fs;
A1 = -results.FrequencyResponseFunction(:,2).*exp(1i*2*pi*freq*1.1e-3);
A2 = -results.FrequencyResponseFunction(:,3)./(1i*2*pi*freq)*9.81;
A2(isinf(A2)) = 0;

a1 = ifft(A1,'symmetric');
a2 = ifft(A2,'symmetric');


figure
subplot(4,1,1)
semilogx(freq, 20*log10(abs(A1)));
hold on
semilogx(freq, 20*log10(abs(A2)),'r');
xlabel('f -> [Hz]')
grid on
title('Abs')
legend('Laser','Acc.meter')
xlim([20,2e3])

subplot(4,1,2)
semilogx(freq, (angle(A1)));
hold on
semilogx(freq, (angle(A2)),'r');
xlabel('f -> [Hz]')
grid on
title('Angle')
legend('Laser','Acc.meter')
xlim([20,2e3])


subplot(4,1,3)
semilogx(freq, real(A1));
hold on
semilogx(freq, real(A2),'r');
xlabel('f -> [Hz]')
grid on
title('Real')
legend('Laser','Acc.meter')
xlim([20,2e3])

subplot(4,1,4)
semilogx(freq, imag(A1));
hold on
semilogx(freq, imag(A2),'r');
xlabel('f -> [Hz]')
grid on
xlim([20,2e3])
title('Imag')
legend('Laser','Acc.meter')
%%
Z = 1./A;
Z0 = 1.2*343;
alpha = 1 - ( abs((Z-Z0)./(Z+Z0))  ).^2;
figure
semilogx(freq, alpha);
xlabel('f -> [Hz]')
grid on
xlim([20,2e3])

