function Drot = rotatepat(az,el,D,axis,ang)
% This function is only for supporting the array modeling with infinite
% array analysis example. It may be removed in future release.

%   Copyright 2015 The MathWorks, Inc.

[AZ,EL] = meshgrid(az*pi/180,el*pi/180);
[x,y,z] = sph2cart(AZ,EL,D);
p = [x(:)';y(:)';z(:)'];
prot = em.internal.rotateshape(p,[0 0 0],axis,ang);
xr = reshape(prot(1,:),size(AZ,1),size(AZ,2));
yr = reshape(prot(2,:),size(AZ,1),size(AZ,2));
zr = reshape(prot(3,:),size(AZ,1),size(AZ,2));
[AZr,ELr,Drot] = cart2sph(xr,yr,zr);
Drot = interp2(AZ,EL,D,AZr,ELr,'nearest');
% Drot = sqrt(xr.^2 + yr.^2 + zr.^2);
end