function [R3,R4,R5] = marsis_reflectivity(strat,eps_strat)
%CALCULATES EFFECTIVE REFLECTIVITY OF A GIVEN SPLD STRATIGRAPHY AT EACH MARSIS
%FREQUENCY
%strat: vector of layer thicknesses
%eps_strat: vector of layer permittivities

eps_ice             = matzler(4e6,175);
eps_base            = 8.8 - 1i*((2e-2)*8.8);
freqband            = linspace(0,1e6,1000);

R3freqs = NaN(length(freqband),1);
R4freqs = NaN(length(freqband),1);
R5freqs = NaN(length(freqband),1);

for ii = 1:length(freqband)
    [~, R4freqs(ii),~,~] = multi_layer_rta(strat,[eps_ice; conj(eps_strat); eps_base],[1; ones(size(strat,1),1); 1],(3.5e6)+freqband(ii),0,0);
    [~, R3freqs(ii),~,~] = multi_layer_rta(strat,[eps_ice; conj(eps_strat); eps_base],[1; ones(size(strat,1),1); 1],(2.5e6)+freqband(ii),0,0);
    [~, R5freqs(ii),~,~] = multi_layer_rta(strat,[eps_ice; conj(eps_strat); eps_base],[1; ones(size(strat,1),1); 1],(4.5e6)+freqband(ii),0,0);
end

R3lin = 10.^(R3freqs./10);
R4lin = 10.^(R4freqs./10);
R5lin = 10.^(R5freqs./10);

R3 = 10.*log10(mean(R3lin));
R4 = 10.*log10(mean(R4lin));
R5 = 10.*log10(mean(R5lin));

end