📄 arpat.m
字号:
function arpat(action)
% filename: arpat.m (v2.1: qloss and dif. beam fixed in arpat.m)
% (v2.2: dif. beam fixed in getamplitudes.m)
% HAS EXPORT OF DATA TO FILE PLOTDAT
% pedval lists corrected 9/03
% Project: 2-D Array Antenna Pattern
% Description: This program implements the functionalities of the
% 2-D Array Antenna Patter GUI, computes the Array Factor
% and performs the calculations requested by the user.
% Author: Prof. David C. Jenn and Elmo E. Garrido Jr.
% Date: 16 September 2000
% Place: NPS
switch(action)
case 'PStart'
h_pstart = findobj(gcf,'Tag','PStart');
pstart_str = get(h_pstart,'String');
pstart = getPStart(pstart_str);
set(h_pstart,'String',num2str(pstart));
case 'PStop'
h_pstop = findobj(gcf,'Tag','PStop');
pstop_str = get(h_pstop,'String');
pstop = getPStop(pstop_str);
set(h_pstop,'String',num2str(pstop));
case 'Delp'
h_delp = findobj(gcf,'Tag','Delp');
delp_str = get(h_delp,'String');
delp = getDelp(delp_str);
set(h_delp,'String',num2str(delp));
case 'TStart'
h_tstart = findobj(gcf,'Tag','TStart');
tstart_str = get(h_tstart,'String');
tstart = getTStart(tstart_str);
set(h_tstart,'String',num2str(tstart));
case 'TStop'
h_tstop = findobj(gcf,'Tag','TStop');
tstop_str = get(h_tstop,'String');
tstop = getTStop(tstop_str);
set(h_tstop,'String',num2str(tstop));
case 'Delt'
h_delt = findobj(gcf,'Tag','Delt');
delt_str = get(h_delt,'String');
delt = getDelt(delt_str);
set(h_delt,'String',num2str(delt));
case 'Nx'
h_Nx = findobj(gcf,'Tag','Nx');
nx_str = get(h_Nx,'String');
Nx = getNEL(nx_str);
set(h_Nx,'String',num2str(Nx));
if Nx == 1
dx = 0;
set(findobj(gcf,'Tag','Dx'),'String',num2str(dx));
warndlg('For a single element, array spacing is set to zero.',...
' Array Spacing','help');
elseif Nx > 1
dx = str2num(get(findobj(gcf,'Tag','Dx'),'String'));
if dx == 0
set(findobj(gcf,'Tag','Dx'),'String',num2str(1));
warndlg('For the number of elements, array spacing cannot be zero.',...
' Array Spacing','help');
end
end
case 'Ny'
h_Ny = findobj(gcf,'Tag','Ny');
ny_str = get(h_Ny,'String');
Ny = getNEL(ny_str);
set(h_Ny,'String',num2str(Ny));
if Ny == 1
dy = 0;
set(findobj(gcf,'Tag','Dy'),'String',num2str(dy));
warndlg('For a single element, array spacing is set zero.',...
' Array Spacing','help');
elseif Ny > 1
dy = str2num(get(findobj(gcf,'Tag','Dy'),'String'));
if dy == 0
set(findobj(gcf,'Tag','Dy'),'String',num2str(1));
warndlg('For the number of elements, array spacing cannot be zero.',...
' Array Spacing','help');
end
end
case 'Dx'
h_Dx = findobj(gcf,'Tag','Dx');
dx_str = get(h_Dx,'String');
dx = getSpacing(dx_str);
set(h_Dx,'String',num2str(dx));
if dx == 0
Nx = 1;
set(findobj(gcf,'Tag','Nx'),'String',num2str(Nx));
warndlg('Number of array elements set to 1.',' Number of Array Elements','help');
end
Nx = str2num(get(findobj(gcf,'Tag','Nx'),'String'));
if dx > 0
if Nx == 1
errordlg('For the spacing indicated, number of elements must be at least 2.',...
'Number of Elements','error');
dx = 0;
set(h_Dx,'String',num2str(dx));
end
end
case 'Dy'
h_Dy = findobj(gcf,'Tag','Dy');
dy_str = get(h_Dy,'String');
dy = getSpacing(dy_str);
set(h_Dy,'String',num2str(dy));
if dy == 0
Ny = 1;
set(findobj(gcf,'Tag','Ny'),'String',num2str(Ny));
warndlg('Number of array elements set to 1.',...
' Number of Array Elements','warn');
end
Ny = str2num(get(findobj(gcf,'Tag','Ny'),'String'));
if dy > 0
if Ny == 1
errordlg('For the spacing indicated, number of elements must be at least 2.',...
'Number of Elements','error');
dy = 0;
set(h_Dy,'String',num2str(dy));
end
end
case 'XDist'
h_XDist = findobj(gcf,'Tag','XDist');
xval = get(h_XDist,'Value');
ixdist = xval;
if (ixdist == 2 | ixdist == 4)
Nx = str2num(get(findobj(gcf,'Tag','Nx'),'String'));
if rem(Nx,2) ~= 0
set(findobj(gcf,'Tag','XDist'),'Value',1);
errordlg('Number of array elements in X-plane must be even. Change number of elements or select another distribution.', ...
' Number of Array Elements','error');
end
end
if (ixdist == 2) |(ixdist == 3) |(ixdist == 4)
set(findobj(gcf,'Tag','PedVal1'),'Enable','on');
set(findobj(gcf,'Tag','ExpVal1'),'Enable','on');
else
set(findobj(gcf,'Tag','PedVal1'),'Enable','off');
set(findobj(gcf,'Tag','ExpVal1'),'Enable','off');
end
case 'YDist'
h_YDist = findobj(gcf,'Tag','YDist');
yval = get(h_YDist,'Value');
iydist = yval;
if iydist == 2 | iydist == 4
Ny = str2num(get(findobj(gcf,'Tag','Ny'),'String'));
if rem(Ny,2) ~= 0
set(findobj(gcf,'Tag','YDist'),'Value',1);
errordlg('Number of array elements in Y-plane must be even. Change number of elements or select another distribution.', ...
' Number of Array Elements','error');
end
end
if (iydist == 2) |(iydist == 3) |(iydist == 4)
set(findobj(gcf,'Tag','PedVal2'),'Enable','on');
set(findobj(gcf,'Tag','ExpVal2'),'Enable','on');
else
set(findobj(gcf,'Tag','PedVal2'),'Enable','off');
set(findobj(gcf,'Tag','ExpVal2'),'Enable','off');
end
case 'PedVal1'
h_PedVal1 = findobj(gcf,'Tag','PedVal1');
pedval1 = get(h_PedVal1,'Value');
switch pedval1
case 1
peddb = 15;
case 2
peddb = 20;
case 3
peddb = 25;
case 4
peddb = 30;
case 5
peddb = 35;
case 6
peddb = 40;
case 7
peddb = 45;
case 8
peddb = 50;
end
case 'ExpVal1'
h_ExpVal1 = findobj(gcf,'Tag','ExpVal1');
expval1 = get(h_ExpVal1,'Value');
nexpx = expval1;
case 'PedVal2'
h_PedVal2 = findobj(gcf,'Tag','PedVal2');
pedval2 = get(h_PedVal2,'Value');
switch pedval2
case 1
peddb = 15;
case 2
peddb = 20;
case 3
peddb = 25;
case 4
peddb = 30;
case 5
peddb = 35;
case 6
peddb = 40;
case 7
peddb = 45;
case 8
peddb = 50;
end
case 'ExpVal2'
h_ExpVal2 = findobj(gcf,'Tag','ExpVal2');
expval2 = get(h_ExpVal2,'Value');
nexpy = expval2;
case 'ThScan'
h_ThScan = findobj(gcf,'Tag','ThScan');
thscan_str = get(h_ThScan,'String');
ths = getScanAngle(thscan_str);
set(h_ThScan,'String',num2str(ths));
case 'PhScan'
h_PhScan = findobj(gcf,'Tag','PhScan');
phscan_str = get(h_PhScan,'String');
phs = getScanAngle(phscan_str);
set(h_PhScan,'String',num2str(phs));
case 'Rectangular'
if get(findobj(gcf,'Tag','Rectangular'),'Value') == 1
set(findobj(gcf,'Tag','Polar'),'Value',0);
elseif get(findobj(gcf,'Tag','Rectangular'),'Value') == 0
set(findobj(gcf,'Tag','Polar'),'Value',1);
end
case 'Polar'
if get(findobj(gcf,'Tag','Polar'),'Value') == 1
set(findobj(gcf,'Tag','Rectangular'),'Value',0);
elseif get(findobj(gcf,'Tag','Polar'),'Value') == 0
set(findobj(gcf,'Tag','Rectangular'),'Value',1);
end
% roundoff values
case 'IPh'
iph = get(findobj(gcf,'Tag','IPh'),'Value');
case 'Bits'
bitz = get(findobj(gcf,'Tag','Bits'),'Value');
nbits=bitz-1;
case 'Calculate'
Nx = str2num(get(findobj(gcf,'Tag','Nx'),'String'));
Ny = str2num(get(findobj(gcf,'Tag','Ny'),'String'));
dx = str2num(get(findobj(gcf,'Tag','Dx'),'String'));
dy = str2num(get(findobj(gcf,'Tag','Dy'),'String'));
ixdist = get(findobj(gcf,'Tag','XDist'),'Value');
iydist = get(findobj(gcf,'Tag','YDist'),'Value');
if Nx > 1
if dx == 0
errordlg('Please set array spacing in X-axis or change the number of elements.',...
'Array Spacing','error');
end
elseif dx > 0
if Nx == 1
errordlg('Please change array spacing in X-axis or the number of elements.',...
'Array Spacing','error');
end
end
if Ny > 1
if dy == 0
errordlg('Please set array spacing in Y-axis or change the number of elements.',...
'Array Spacing','error');
end
elseif dy > 0
if Ny == 1
errordlg('Please change array spacing in Y-axis or the number of elements.',...
'Array Spacing','error');
end
end
% get parameters
bk = 2*pi;
rad = pi/180;
pstart = str2num(get(findobj(gcf,'Tag','PStart'),'String'));
pstop = str2num(get(findobj(gcf,'Tag','PStop'),'String'));
delp = str2num(get(findobj(gcf,'Tag','Delp'),'String'));
tstart = str2num(get(findobj(gcf,'Tag','TStart'),'String'));
tstop = str2num(get(findobj(gcf,'Tag','TStop'),'String'));
delt = str2num(get(findobj(gcf,'Tag','Delt'),'String'));
it = floor((tstop-tstart)/delt)+ 1;
ip = floor((pstop-pstart)/delp)+ 1;
Nx = str2num(get(findobj(gcf,'Tag','Nx'),'String'));
Ny = str2num(get(findobj(gcf,'Tag','Ny'),'String'));
dx = str2num(get(findobj(gcf,'Tag','Dx'),'String'));
dy = str2num(get(findobj(gcf,'Tag','Dy'),'String'));
ixdist = get(findobj(gcf,'Tag','XDist'),'Value');
iydist = get(findobj(gcf,'Tag','YDist'),'Value');
iph = get(findobj(gcf,'Tag','IPh'),'Value');
nbits = get(findobj(gcf,'Tag','Bits'),'Value')-1;
ths = str2num(get(findobj(gcf,'Tag','ThScan'),'String'));
phs = str2num(get(findobj(gcf,'Tag','PhScan'),'String'));
if ixdist == 1, disp('in x: Uniform distribution'); end
if ixdist == 2, disp('in x: Taylor distribution'); end
if ixdist == 3, disp('in x: Cosine distribution'); end
if ixdist == 4, disp('in x: Bayliss distribution'); end
if ixdist == 5, disp('in x: Triangular distribution'); end
if iydist == 1, disp('in y: Uniform distribution'); end
if iydist == 2, disp('in y: Taylor distribution'); end
if iydist == 3, disp('in y: Cosine distribution'); end
if iydist == 4, disp('in y: Bayliss distribution'); end
if iydist == 5, disp('in y: Triangular distribution'); end
msg = ['Computing array pattern for ',num2str(it*ip),' angles'];
hwait=waitbar(0,msg);
pause(0.1);
[ampxn,ampyn] = getamplitudes(Nx,ixdist,Ny,iydist);
% calculate aperture efficiency
s1=0; s2=0;
for i1=1:Nx
for i2=1:Ny
s1=s1+abs(ampxn(i1)*ampyn(i2)); s2=s2+abs(ampxn(i1)*ampyn(i2))^2;
end
end
eta=s1^2/Nx/Ny/s2;
% disp(['aperture efficiency: ',num2str(eta)])
% determine the phase distribution
us = sin(ths*rad)*cos(phs*rad);
vs = sin(ths*rad)*sin(phs*rad);
psix = bk*dx*us;
psiy = bk*dy*vs;
% generate exact phase required at each element.
% positive scan corresponds to increasing phase lag with increasing n.
xsix = -(2*[1:Nx] - (Nx + 1))/2*psix;
xminx = min(xsix(1),xsix(Nx));
xsix(1:Nx)=xsix(1:Nx)-xminx;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -