Home > wafo > spec > createcov.m

createcov

PURPOSE ^

Covariance class constructor

SYNOPSIS ^

R=createcov(nr,vari,ctype)

DESCRIPTION ^

  CREATECOV Covariance class constructor 
  
  CALL:  R=createcov(nr,variables,ctype) 
   
          nr = number of derivatives (default 0   ) 
   variables = 'xyt'                 (default 't' ) 
        ctype = 'enc', 'none'   (default none) 
  
  Example: R=createcov(1,'tx') create a structure with proper fieldnames for covariance 
             
        R: [] 
        x: [] 
        t: [] 
        h: Inf 
       tr: [] 
     type: 'none' 
     norm: [] 
       Rx: [] 
       Rt: [] 
     note: [] 
     date: '16-Sep-1999, 09:50:44' 
  
  See also  createspec, datastructures

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function R=createcov(nr,vari,ctype) 
002 % CREATECOV Covariance class constructor 
003 % 
004 % CALL:  R=createcov(nr,variables,ctype) 
005 %  
006 %         nr = number of derivatives (default 0   ) 
007 %  variables = 'xyt'                 (default 't' ) 
008 %       ctype = 'enc', 'none'   (default none) 
009 % 
010 % Example: R=createcov(1,'tx') create a structure with proper fieldnames for covariance 
011 %            
012 %       R: [] 
013 %       x: [] 
014 %       t: [] 
015 %       h: Inf 
016 %      tr: [] 
017 %    type: 'none' 
018 %    norm: [] 
019 %      Rx: [] 
020 %      Rt: [] 
021 %    note: [] 
022 %    date: '16-Sep-1999, 09:50:44' 
023 % 
024 % See also  createspec, datastructures 
025  
026 %Tested on: Matlab 5.3 
027 %History: 
028 % by pab 12.08.99 
029  
030 if nargin<1|isempty(nr) 
031   nr = 0; 
032 end 
033 if nargin<2|isempty(vari) 
034   vari = 't'; 
035   Nv   = 1; 
036 else 
037   vari = sort(lower(vari)); 
038   Nv   = length(vari); 
039   if ( (vari(1)=='t') & (Nv>1)), 
040     vari = [vari(2:Nv), 't']; 
041   end  
042 end 
043  
044 if nargin<3|isempty(ctype) 
045   ctype='none'; 
046 end 
047  
048 R=struct('R',[]); 
049 for ix=1:Nv 
050   R = setfield(R,vari(ix),[]); 
051 end 
052 if Nv==1, 
053   R.stdev=[]; 
054 end 
055 R.h=inf; 
056 R.tr=[]; 
057 R.phi=0; 
058 if strcmp(ctype(1:3),'enc') 
059    R.v=0; 
060 end 
061 R.type=ctype; 
062 R.norm=[]; 
063  
064 % initialize struct 
065 switch Nv 
066  case 1,  
067   fieldname = vari(ones(1,nr));  
068   for ix=1:nr 
069     R = setfield(R,fieldname(1:ix),[]); 
070   end    
071 case 2, 
072   for ix=1:nr 
073     for iy=0:nr-ix 
074       tmp=[vari(ones(1,ix),1)' vari(ones(1,iy),2)']; 
075       eval(['R.R' tmp '=[];'  ]) 
076     end 
077   end    
078   for ix=1:nr 
079     tmp=vari(ones(1,ix),2)'; 
080     eval(['R.R' tmp '=[];']) 
081   end    
082 case 3, 
083  for ix=1:nr 
084     for iy=0:nr-ix 
085       for iz=0:nr-ix-iy 
086         tmp=[vari(ones(1,ix),1)' vari(ones(1,iy),2)' vari(ones(1,iz),3)']; 
087         eval(['R.R' tmp '=[];' ]) 
088       end 
089     end 
090   end    
091   for ix=1:nr 
092     for iy=0:nr-ix 
093        tmp=[vari(ones(1,ix),2)' vari(ones(1,iy),3)']; 
094       eval(['R.R' tmp '=[];' ]) 
095     end 
096   end    
097   for ix=1:nr 
098     tmp=vari(ones(1,ix),3)'; 
099     eval(['R.R' tmp '=[];']) 
100   end    
101  
102 otherwise, error('unknown # variables') 
103 end 
104  
105 R.note=[]; 
106 R.date=datestr(now); 
107

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003