%Function to show the beampattern for a lambda/2 interspace ULA
%v_0: weight vector as a steering vector.
%phiVec: angle vector to plot the beampattern
function [bp,phiVec]=fLAbp(lambda,d,v_0,sub_pos)

 
%calculate the beam pattern
phiVec=(-90:1/2:90)*pi/180; 
theta_scan = pi/2; 

%%
%keyboard
for loop=1:length(phiVec),
    phi_scan=phiVec(loop);
    
    %For ULA
    xnor = sin(theta_scan)*cos(phi_scan);
    ynor = sin(theta_scan)*sin(phi_scan);
    znor = cos(theta_scan);
    DOA_scan=[xnor;ynor;znor];
    
    s_scan=exp(j*2*pi/lambda*sub_pos*DOA_scan); %Column steering vector
    bp(loop)=abs(s_scan'*v_0)^2;
end; %for loop=1:length(phiVec),

%% Beampattern Plot
%plot(phiVec/pi*180,10*log10(bp),'DisplayName',['Delay-and-Sum'],'LineStyle','--',...
%    'LineWidth',2,'Color',[0 0 0]);
