results = load('Laser_and_microflown\final_measurement_000.mat');
results = results.Result;

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

freq = (0:N/2)'/N*fs;
hammer = results.FrequencyResponseFunction(:,1);
lazer = -results.FrequencyResponseFunction(:,3).*exp(1i*2*pi*freq*1.1e-3);
mic = results.FrequencyResponseFunction(:,2);
mfP = results.FrequencyResponseFunction(:,4);
mfV = -results.FrequencyResponseFunction(:,5);

c = 343;
rho0 = 1.2;
Z0 = rho0*c;
w = 2*pi*freq;
d = 1e-2;
dA = 0.88*0.6;
Z_ldv = 1./lazer/dA;
Zm = mfP./mfV;
Z_mf = ( Zm -1i*Z0.*tan(w*d/c)  )./( Z0 - 1i*Zm.*tan(w*d/c) );
alpha1 = 1 - abs(( (Z_ldv-Z0)./(Z_ldv+Z0))).^2;
alpha2 = 1 - abs(( (Z_mf-Z0)./(Z_mf+Z0))).^2;
figure
semilogx(freq, alpha1);
xlabel('f -> [Hz]')
hold on
%semilogx(freq, alpha2,'--r');
grid on
xlim([20,1e3])
