Home > functions > leadfield > spherical_harmo > vb_spherical_harmo_W.m

vb_spherical_harmo_W

PURPOSE ^

spherical harmonics W

SYNOPSIS ^

function [W, valid] = vb_spherical_harmo_W(n, m, F, Itbl, p_z_m, c_s)

DESCRIPTION ^

 spherical harmonics W
 [usage]
   [W, valid] = vb_spherical_harmo_W(n, m, F, Itbl, p_z_m, c_s)
 [input]
       n : index of n-term of legendre
       m : index of m-term of legendre
       F : spherical harmonics functions
    Itbl : index table of n and m for cosine and sine (n x m x 2)
   p_z_m : [string] plus('+') or zero('0') or minus('-')
     c_s : [short]  cosine or sine flag : 0(cosine), 1(sine)
 [output]
       W : calculated W-term
   valid : validity of this calculation (true or false)
 [note]

 [history]
   2006.06.22 (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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [W, valid] = vb_spherical_harmo_W(n, m, F, Itbl, p_z_m, c_s)
0002 % spherical harmonics W
0003 % [usage]
0004 %   [W, valid] = vb_spherical_harmo_W(n, m, F, Itbl, p_z_m, c_s)
0005 % [input]
0006 %       n : index of n-term of legendre
0007 %       m : index of m-term of legendre
0008 %       F : spherical harmonics functions
0009 %    Itbl : index table of n and m for cosine and sine (n x m x 2)
0010 %   p_z_m : [string] plus('+') or zero('0') or minus('-')
0011 %     c_s : [short]  cosine or sine flag : 0(cosine), 1(sine)
0012 % [output]
0013 %       W : calculated W-term
0014 %   valid : validity of this calculation (true or false)
0015 % [note]
0016 %
0017 % [history]
0018 %   2006.06.22 (Sako) initial version
0019 %
0020 % Copyright (C) 2011, ATR All Rights Reserved.
0021 % License : New BSD License(see VBMEG_LICENSE.txt)
0022 
0023 W = zeros(size(F,1),1);
0024 valid = true;
0025 
0026 if c_s ~= 0 & c_s ~= 1
0027   disp('c_s is allowed to set 0(cosine) or 1(sine)');
0028   valid = false;
0029   return;
0030 end
0031 
0032 nn = n-1;
0033 
0034 switch  p_z_m
0035   case  '+'
0036     a = a_param(n,m,'+');
0037     mm = m+1;
0038     W  = vb_get_spherical_harmo(nn,mm,F,Itbl,c_s);
0039     W  = a * W;
0040 
0041   case  '-'
0042     a = a_param(n,m,'-');
0043     mm = m-1;
0044     W  = vb_get_spherical_harmo(nn,mm,F,Itbl,c_s);
0045     W  = a * W;
0046     
0047   case  '0'
0048     a = a_param(n,m,'0');
0049     mm = m;
0050     W  = vb_get_spherical_harmo(nn,mm,F,Itbl,c_s);
0051     W  = a * W;
0052     
0053   otherwise
0054 end
0055 
0056 
0057 % func : calculate 'a' value
0058 % [usage]
0059 %   a = a_param( n, m, p_z_m )
0060 % [input]
0061 %       n : index of n-term of legendre
0062 %       m : index of m-term of legendre
0063 %   p_z_m : plus('+') or zero('0') or minus('-')
0064 % [output]
0065 %       a : calculated 'a' value
0066 function a = a_param(n,m,p_z_m)
0067 
0068 % Normalized Legendre function case
0069   switch  p_z_m
0070     case  '+'
0071       if m < n-1 & n > 0, 
0072           a = (n-m)*(n-m-1)*(2*n+1)/(2*n-1);
0073           a = -sqrt(a);
0074       else
0075           a=0; 
0076       end
0077     case  '-'
0078       if n > 0, 
0079           a = (m+n)*(m+n-1)*(2*n+1)/(2*n-1);
0080           a = sqrt(a);
0081       else
0082           a=0; 
0083       end
0084     case  '0'
0085       if m < n & n > 0, 
0086           a = (m+n)*(n-m)*(2*n+1)/(2*n-1);
0087           a = sqrt(a);
0088       else
0089           a=0; 
0090       end
0091   end
0092   return;
0093

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005