function scanURA(myURA1,freq,azang_plot,elang_plot,DSEP1_Enormlz,DSEP1_Hnormlz)
% This function is only for supporting the array modeling with infinite
% element pattern example. It may be removed in future release.

%   Copyright 2015 The MathWorks, Inc.

scan_ang = [-30 0 30];
scan_az1 = zeros(1,numel(scan_ang));
scan_el1 = zeros(1,numel(scan_ang));
scanEplane = [scan_az1;scan_ang];
scanHplane = [scan_ang;scan_el1];
hsvE = phased.SteeringVector;
hsvH = phased.SteeringVector;
hsvE.SensorArray = myURA1;
hsvH.SensorArray = myURA1;
hsvE.IncludeElementResponse = true;
hsvH.IncludeElementResponse = true;
weightsE = step(hsvE,freq,scanEplane);
weightsH = step(hsvE,freq,scanHplane);
legend_string = cell(1,numel(scan_ang)+1);
legend_string{end} = 'SEP';
scanEPat = nan(numel(elang_plot),numel(scan_ang));
scanHPat = nan(numel(elang_plot),numel(scan_ang));
for i = 1:numel(scan_ang)
    scanEPat(:,i) = pattern(myURA1,freq,scan_az1(i),elang_plot,'Weights',weightsE(:,i)); 
    scanHPat(:,i) = pattern(myURA1,freq,azang_plot,scan_el1(i),'Weights',weightsH(:,i)); 
    legend_string{i} = strcat('scan = ',num2str(scan_ang(i)));
end

% *E-plane and H-plane Scan*
scanEPat = scanEPat - max(max(scanEPat));
scanHPat = scanHPat - max(max(scanHPat));
figure;
subplot(211)
plot(elang_plot,scanEPat,'LineWidth',1.5);
hold on
grid on
plot(elang_plot,DSEP1_Enormlz,'-.','LineWidth',1.5);
axis([min(elang_plot) max(elang_plot) -40 0])
xlabel('Elevation (deg.)')
ylabel('Directivity (dB)')
title('E-plane Scan')
legend(legend_string)
hold off
subplot(212)
plot(azang_plot,scanHPat,'LineWidth',1.5);
hold on
grid on
plot(azang_plot,DSEP1_Hnormlz,'-.','LineWidth',1.5);
axis([min(azang_plot) max(azang_plot) -40 0])
xlabel('Azimuth (deg.)')
ylabel('Directivity (dB)')
title('H-plane Scan')
legend(legend_string)
hold off


end