xPos = -0.8:0.2:0.8;
yPos = zeros(1, numel(xPos));
zPos = zeros(1, numel(xPos));
elementWeights = ones(1, numel(xPos))/numel(xPos);
thetaArrivalAngles = [-30 10];
phiArrivalAngles = [0 0];
f = 800;
c = 340;
fs = 44.1e3;
thetaScanAngles = -90:0.1:90;
phiScanAngles = 0;
inputSignal = createSignal(xPos, yPos, zPos, f, c, fs, thetaArrivalAngles, phiArrivalAngles);
e = steeringVector(xPos, yPos, zPos, f, c, thetaScanAngles, phiScanAngles);
R = crossSpectralMatrix(inputSignal);
S = steeredResponseDelayAndSum(R, e, elementWeights);
spectrumNormalized = abs(S)/max(abs(S));
spectrumLog = 10*log10(spectrumNormalized);
fig1 = figure;
fig1.Color = 'w';
ax = axes('Parent', fig1);
scatter(ax, xPos, yPos, 20, 'filled')
axis(ax, 'square')
ax.XLim = [-1 1];
ax.YLim = [-1 1];
grid(ax, 'on')
title(ax, 'Microphone positions')
fig2 = figure;
fig2.Color = 'w';
ax = axes('Parent', fig2);
plot(ax, thetaScanAngles, spectrumLog)
grid(ax, 'on')
ax.XLim = [thetaScanAngles(1) thetaScanAngles(end)];
for j=1:numel(thetaArrivalAngles)
indx = find(thetaScanAngles >= thetaArrivalAngles(j), 1);
line(ax, [thetaScanAngles(indx) thetaScanAngles(indx)], ax.YLim,'LineWidth', 1, 'Color', 'r', 'LineStyle', '--');
end
xlabel(ax, '\theta')
ylabel(ax, 'dB')