Home > vbmeg > functions > leadfield > spherical_harmo > vb_get_spherical_harmo.m

vb_get_spherical_harmo

PURPOSE ^

return spherical harmonics value by using legendre index table

SYNOPSIS ^

function [F_nm, validity] = vb_get_spherical_harmo(n,m,F,Itbl,c_s)

DESCRIPTION ^

 return spherical harmonics value by using legendre index table
 [usage]
   [ F_nm, validity ] = vb_get_spherical_harmo( n, m, F, Itbl, c_s)
 [input]
          n : n value of spherical harmonics (n=1:N)
          m : m value of spherical harmonics (m=0:n)
          F : matrix of value of spherical harmonics
       ltbl : index table of legendre
        c_s : cosine(0) or sine(1)
 [output]
       F_nm : (n,m)element of matrix F
   validity : validity of F_nm. valid(true) or invalid(false)
 [note]
 
 [history]
   2006.08.24 (Sako) initial version

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [F_nm, validity] = vb_get_spherical_harmo(n,m,F,Itbl,c_s)
0002 % return spherical harmonics value by using legendre index table
0003 % [usage]
0004 %   [ F_nm, validity ] = vb_get_spherical_harmo( n, m, F, Itbl, c_s)
0005 % [input]
0006 %          n : n value of spherical harmonics (n=1:N)
0007 %          m : m value of spherical harmonics (m=0:n)
0008 %          F : matrix of value of spherical harmonics
0009 %       ltbl : index table of legendre
0010 %        c_s : cosine(0) or sine(1)
0011 % [output]
0012 %       F_nm : (n,m)element of matrix F
0013 %   validity : validity of F_nm. valid(true) or invalid(false)
0014 % [note]
0015 %
0016 % [history]
0017 %   2006.08.24 (Sako) initial version
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 % temporary value
0023 validity   = false;
0024 column_num = 0;
0025 
0026 F_nm = zeros(size(F,1),1);
0027 
0028 % convert from legendre number to matrix index
0029 IdxNN = n + 1;
0030 
0031 if m >= 0, 
0032     IdxMM = m + 1;
0033 else
0034     IdxMM = -m + 1;
0035 end
0036 
0037 if n < m, 
0038     return
0039 end
0040 if IdxNN < 1 | IdxNN > size(Itbl,1) | IdxMM < 1 | IdxMM > size(Itbl,2)
0041     return
0042 end
0043 
0044 if  c_s == 0    % cosine
0045     column_num = Itbl(IdxNN,IdxMM,1);
0046     
0047     if column_num < 1, return; end;
0048     
0049     if m >= 0, 
0050         F_nm = F(:,column_num);
0051     else
0052         % Normalized Legendre function case
0053         F_nm = -F(:,column_num);
0054     end
0055 elseif c_s == 1 % sine
0056     column_num = Itbl(IdxNN,IdxMM,2);
0057     
0058     if column_num < 1, return; end;
0059 
0060     if m >= 0, 
0061         F_nm = F(:,column_num);
0062     else
0063         % Normalized Legendre function case
0064         F_nm = F(:,column_num);
0065     end
0066 end
0067 
0068 validity = true;
0069 return
0070

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005