clear;
N = 11; % mic num
d = 0.05; % distance
c = 340; % speed
fc = 1700; % freq
theta_d = pi * 90 / 180; % in angle
%%%%%%%%%%%% 90 %%%%%%%%%%%%%%%
[B_db_90,theta] = LineBeamPattern(N,fc,d,c,theta_d);
limit_dB = -50;
index = B_db_90 < limit_dB;
B_db_90(index) = limit_dB;
figure(1);
subplot(4,2,1);
plot(theta*180/pi, real(B_db_90),'linewidth', 1.5);
grid on;xlabel('angle');ylabel('20lg(B)/db');
title('90');
subplot(4,2,2)
hpol=polardb(theta,B_db_90,limit_dB,'-r');
%%%%%%%%%%%% 120 %%%%%%%%%%%%%%%
theta_d = 120 * pi / 180;
[B_db_120,theta] = LineBeamPattern(N,fc,d,c,theta_d);
limit_dB = -50;
index = B_db_120 < limit_dB;
B_db_120(index) = limit_dB;
figure(1);
subplot(4,2,3);
plot(theta*180/pi, real(B_db_120),'linewidth', 1.5);
grid on;xlabel('angle');ylabel('20lg(B)/db');
title('120');
subplot(4,2,4)
hpol=polardb(theta,B_db_120,limit_dB,'-r');
%%%%%%%%%%%% 180 %%%%%%%%%%%%%%%
theta_d = 180 * pi / 180;
[B_db_180,theta] = LineBeamPattern(N,fc,d,c,theta_d);
limit_dB = -50;
index = B_db_180 < limit_dB;
B_db_180(index) = limit_dB;
figure(1);
subplot(4,2,5);
plot(theta*180/pi, real(B_db_180),'linewidth', 1.5);
grid on;xlabel('angle');ylabel('20lg(B)/db');
title('180');
subplot(4,2,6)
hpol=polardb(theta,B_db_180,limit_dB,'-r');
%%%%%%%%%%%% 90 null 155 %%%%%%%%%%%%%%%
theta_d = 90 * pi / 180;
theta_null = 155 * pi / 180;
[B_db_null,theta] = LineBeamPattern(N,fc,d,c,theta_d,theta_null);
limit_dB = -50;
index = B_db_90 < limit_dB;
B_db_null(index) = limit_dB;
figure(1);
subplot(4,2,7);
plot(theta*180/pi, real(B_db_null),'linewidth', 1.5);
grid on;xlabel('angle');ylabel('20lg(B)/db');
title('90, null 155');
subplot(4,2,8)
hpol=polardb(theta,B_db_null,limit_dB,'-r');