function p = g2(theta,phi)

N = length(theta);
p = zeros(1,N);

data = [ -9.000    0.0002; %changed from 10
          -8.0000    0.0218;
          -6.0000    0.0513;
          -5.0000    0.0685;
          -3.0000    0.0859;
          -2.0000    0.0874;
                0    0.0867;
           2.0000    0.0839;
           4.0000    0.0667;
           6.0000    0.0194;
           8.0000    0.0028;
           8.4000         0];
data(:,1) = pi/180*data(:,1);
M = length(data(:,1));

for i = 1:N
    delta = theta(i)-phi;
    if ((data(1,1)<delta)&&(delta<data(M,1)))
        % find the point on the list 'data'
        for j = 1:(M-1)
            if (delta > data(j,1))
                break;
            end
        end
        p(i) = data(j,2)+(data(j+1,2)-data(j,2))/(data(j+1,1)-data(j,1))*(delta-data(j,1));
    else
        p(i) = 0;
    end
end