www.gusucode.com > phased 案例源码 matlab代码程序 > phased/ReplicatedHexagonalArraysOnSphereExample.m

    %% Array of Replicated Hexagonal Arrays on a Sphere
% This example shows how to construct a full array by 
% replicating subarrays.

%%
% Create a hexagonal array to use as a subarray.
Nmin = 9;
Nmax = 17;
dy = 0.5;
dz = 0.5*sin(pi/3);
rowlengths = [Nmin:Nmax Nmax-1:-1:Nmin];
numels_hex = sum(rowlengths);
stopvals = cumsum(rowlengths);
startvals = stopvals-rowlengths+1;
pos = zeros(3,numels_hex);
rowidx = 0;
for m = Nmin-Nmax:Nmax-Nmin
    rowidx = rowidx+1;
    idx = startvals(rowidx):stopvals(rowidx);
    pos(2,idx) = (-(rowlengths(rowidx)-1)/2:...
        (rowlengths(rowidx)-1)/2) * dy;
    pos(3,idx) = m*dz;
end
hexa = phased.ConformalArray('ElementPosition',pos,...
    'ElementNormal',zeros(2,numels_hex));

%%
% Arrange copies of the hexagonal array on a sphere.
radius = 9;
az = [-180 -180 -180 -120 -120 -60 -60   0  0  60 60 120 120 180];
el = [-90   -30   30  -30   30 -30  30 -30 30 -30 30 -30  30  90];
numsubarrays = size(az,2);
[x,y,z] = sph2cart(deg2rad(az),deg2rad(el),...
    radius*ones(1,numsubarrays));
ha = phased.ReplicatedSubarray('Subarray',hexa,...
    'Layout','Custom',...
    'SubarrayPosition',[x; y; z], ...
    'SubarrayNormal',[az; el]);

%%
% Display the geometry of the array, highlighting selected subarrays with different colors.
viewArray(ha,'ShowSubarray',3:2:13,...
    'Title','Hexagonal Subarrays on a Sphere');
view(0,90)