clear;

%-- list of input parameters

f = 1; % freq in GHz
eps = 9 - 1i*1.5; % dielectric constant

%-periodic surface: f(x,y) = -A cos(2 pi y/Gmm)
A = 0.2/2; %Amplitude value in meters
Gmm = 0.95; %period in meters

sp = 1; % 1 for exponential and 2 for gaussian correlation functions
s = 0.9551 / 100; % rms height in m
l = 42.98 / 100; % correl length (m)

%-- vary theta but fix phi
ph_deg = [ 0  90]; %phi = 0 is when radar is parallel to rows
                        %phi = 90 is when radar is perpendicular to rows
n_ph = length(ph_deg);

n_th = 6;  % number of angles
th_start = 0; %start angle in deg
th_stop =50; % stop angle in deg

the_deg = linspace(th_start,th_stop, n_th); %create the vector of incident angles


ev = zeros(n_ph, n_th); % initialize arrays
eh = ev;

for jj = 1: n_ph % loop through all angle combinations of interest to generate the data
    for ii = 1: n_th
        the = the_deg(ii) 
        ph = ph_deg(jj);
        [ev(jj,ii), eh(jj,ii)] = Emissivity_I2EM_Periodic(the,ph ...
         , eps, f, s, l, sp, Gmm, A);

    end
end
Ts = 300;

figure(1) 
plot(the_deg, ev(1,:)*Ts, the_deg, ev(2,:)*Ts )
set(gca, 'FontSize', 12, 'FontWeight', 'b')
xlabel('Incidence Angle \theta (deg)','FontSize',14, 'FontWeight','b')
ylabel('e_v', 'FontSize',14, 'FontWeight','b')
%title('Volume Scattering - Lossy Sand Particles', 'FontSize',16, 'FontWeight','b')
ch = get(gca, 'Children');
set(ch(2),'LineWidth', 1.5, 'LineStyle','-','Color','r')
set(ch(1),'LineWidth', 1.5, 'LineStyle','-','Color','b')
axis([0 50 100 300])
legend ('\phi = 0^o', '\phi = 90^o', 3)
grid


figure(2) 
plot(the_deg, eh(1,:)*Ts, the_deg, eh(2,:)*Ts )
set(gca, 'FontSize', 12, 'FontWeight', 'b')
xlabel('Incidence Angle \theta (deg)','FontSize',14, 'FontWeight','b')
ylabel('e_h', 'FontSize',14, 'FontWeight','b')
%title('Volume Scattering - Lossy Sand Particles', 'FontSize',16, 'FontWeight','b')
ch = get(gca, 'Children');
set(ch(2),'LineWidth', 1.5, 'LineStyle','-','Color','r')
set(ch(1),'LineWidth', 1.5, 'LineStyle','-','Color','b')
axis([0 50 100 300])
legend ('\phi = 0^o', '\phi = 90^o', 3)
grid


