ita_sph_vector2matrix.m 901 Bytes
Newer Older
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 37
function mat = ita_sph_vector2matrix(vec,type)

% <ITA-Toolbox>
% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. 
% You can find the license for this m-file in the application folder. 
% </ITA-Toolbox>

% converts a SH vector into matrix notation
%  the upper corners of the matrix are filled with zeros

% Author: Martin Pollow <mpo@akustik.rwth-aachen.de>

% first dim should be SH coefs
% check for transversed vector
sizeVec = size(vec);
if sizeVec(1) == 1 && sizeVec(2) > 1
    vec = vec.';
    sizeVec = size(vec);
end
nSH = sizeVec(1);

[n,m] = ita_sph_linear2degreeorder(1:nSH);

matSize = [n(end)+1 2*n(end)+1 sizeVec(2)];
if nargin > 1 && strcmpi(type,'nan')
    mat = nan(matSize);
else
    mat = zeros(matSize);
end

for ind = 1:nSH
    for indF = 1:sizeVec(2)
        mat(n(ind)+1,m(ind)+n(end)+1,indF) = vec(ind,indF);
    end
end

end