-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathbeamWeightsFromFunction.m
executable file
·36 lines (32 loc) · 1.36 KB
/
beamWeightsFromFunction.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function b_nm = beamWeightsFromFunction(fHandleArray, order)
%BEAMWEIGHTSFROMFUNCTION Generate spherical beamweights for arbitrary pattern
%
% This function computes the SH coefficients of an arbitrary target
% beampattern, by performing the SHT on it. The pattern should be
% specified as a function handle that expects a Kx1 vector of azimuths as
% first argument, and a vector of Kx1 elevations as the second argument,
% and return the functions values for these K directions.
% Multiple patterns can be passed as an array of function handles.
% The order specifies the maximum SH order of the beamweights.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% BEAMWEIGHTSFROMFUNCTION.M - 10/4/2013
% Archontis Politis, [email protected]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% get a dense uniform design
[~, dirsAziElev] = getTdesign(20);
% convert azi-elev to azi-incl
dirsAziInc = [dirsAziElev(:,1) pi/2-dirsAziElev(:,2)];
Nfunc = length(fHandleArray);
b_nm = zeros((order+1)^2, Nfunc);
for nf =1:Nfunc
if Nfunc==1, fPattern = fHandleArray;
else fPattern = fHandleArray{nf};
end
% compute the pattern at grid points
F_dirs = fPattern(dirsAziElev(:,1), dirsAziElev(:,2));
% get harmonic coefficients
b_nm(:,nf) = directSHT(order, F_dirs, dirsAziInc, 'real');
end