Home > wafo > spec > createspec.m

createspec

PURPOSE ^

Spectrum structure constructor

SYNOPSIS ^

S=createspec(stype,freqtype)

DESCRIPTION ^

  CREATESPEC Spectrum structure constructor
 
  CALL:  S=createspec(stype,freqtype)
  
       stype = 'freq'   Frequency spectrum (default)
               'dir'    Directional spectrum
               'k1D'    Wave number spectrum 1D
               'k2D'    Wave number spectrum 2D
               'encdir' Encounter directional spectrum
               'enc'    Encounter frequency spectrum
 
    freqtype = 'w' angular frequency (rad/sec) (default)
               'f' frequency         (Hz)
 
  Example: Create a structure with proper fieldnames for directional spectrum
            S=createspec('dir') 
 
  See also  createcov, datastructures

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function S=createspec(stype,freqtype)
002 % CREATESPEC Spectrum structure constructor
003 %
004 % CALL:  S=createspec(stype,freqtype)
005 % 
006 %      stype = 'freq'   Frequency spectrum (default)
007 %              'dir'    Directional spectrum
008 %              'k1D'    Wave number spectrum 1D
009 %              'k2D'    Wave number spectrum 2D
010 %              'encdir' Encounter directional spectrum
011 %              'enc'    Encounter frequency spectrum
012 %
013 %   freqtype = 'w' angular frequency (rad/sec) (default)
014 %              'f' frequency         (Hz)
015 %
016 % Example: Create a structure with proper fieldnames for directional spectrum
017 %           S=createspec('dir') 
018 %
019 % See also  createcov, datastructures
020 
021 % Tested on: Matlab 5.3
022 % History:
023 %  revised by IR 03.04.2001 - added S.phi=0.
024 %  revised by jr 10.07.2000 - Line 47 and 49: semicolon added
025 %  revised by es 25.05.2000 - help-text changes  
026 %  revised by jr 14.01.2000 - Field added: norm: 0 
027 %  revised by es 19.09.1999
028 %  by pab 12.08.99
029 
030 if nargin<1|isempty(stype)
031   stype='freq';
032 else
033   stype=lower(stype);
034 end
035 
036 if nargin<2|isempty(freqtype)
037   freqtype='w';
038 else
039   freqtype=lower(freqtype);
040 end
041 
042 n=length(stype);
043 S=struct('S',[]);
044 if strcmp(stype(1),'k') % wavenumber spectrum
045   S.k=[];
046   if strcmp(stype(n-1),'2')
047     S.k2=[];
048   end
049 else % 
050   if strcmp(freqtype,'f')
051     S.f=[];
052   else
053     S.w=[];
054   end
055   if strcmp(stype(n-2:n),'dir')
056    S.theta=[];
057   end
058 end
059 
060 S.tr=[];
061 
062 if strcmp(stype(1:3),'enc')
063    S.v=0;
064    S.phi=0;
065 elseif strcmp(stype(1:3),'rot')
066    S.phi=0;
067 end
068 S.h=inf;
069 S.type=stype;
070 S.phi=0.;
071 S.norm=0;
072 S.note=[];
073 S.date=datestr(now);
074

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