Home > wafo > wavemodels > trraylpdf.m

trraylpdf

PURPOSE ^

Calculates transformed Rayleigh approximation for amplitudes

SYNOPSIS ^

f=trraylpdf(x,def,gn,utc)

DESCRIPTION ^

 TRRAYLPDF Calculates transformed Rayleigh approximation for amplitudes 
           
   CALL:  f = trraylpdf(x,def,g,u); 
  
     f    = density structure of wave amplitude f(x); 
  
     x    = a row vector with x-values. 
     def  = 'Ac',    gives wave crest amplitude Ac (default). 
            'At',    gives wave trough amplitude At. 
            'AcAt',  gives wave range Ac+At 
     g    = [y g(y)] a two column matrix with the transformation  g(y). 
     u    = reference level (default the most frequently crossed level). 
  
  Example: 
   np =10000; dt = .2; method = 1 
   x1 = spec2nlsdat(jonswap,np,dt); 
   [S, H,Ac,At] = dat2steep(x1,4,method);  
   gnl = dat2tr(x1,'nonlinear');   % nonlinear transformation 
   gl  = dat2tr(x1,'linear');      % identity transformations   
   x   = linspace(0,8); 
   fnl = trraylpdf(x,'ac',gnl,0);  % with transformation 
   fl  = trraylpdf(x,'ac',gl,0);   % without transformation 
   empdistr(Ac), hold on 
   pdfplot(fnl,11,'g'),  
   pdfplot(fl,11,'r'),  hold off   
  
  See also  wraylpdf

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f=trraylpdf(x,def,gn,utc) 
002 %TRRAYLPDF Calculates transformed Rayleigh approximation for amplitudes 
003 %          
004 %  CALL:  f = trraylpdf(x,def,g,u); 
005 % 
006 %    f    = density structure of wave amplitude f(x); 
007 % 
008 %    x    = a row vector with x-values. 
009 %    def  = 'Ac',    gives wave crest amplitude Ac (default). 
010 %           'At',    gives wave trough amplitude At. 
011 %           'AcAt',  gives wave range Ac+At 
012 %    g    = [y g(y)] a two column matrix with the transformation  g(y). 
013 %    u    = reference level (default the most frequently crossed level). 
014 % 
015 % Example: 
016 %  np =10000; dt = .2; method = 1 
017 %  x1 = spec2nlsdat(jonswap,np,dt); 
018 %  [S, H,Ac,At] = dat2steep(x1,4,method);  
019 %  gnl = dat2tr(x1,'nonlinear');   % nonlinear transformation 
020 %  gl  = dat2tr(x1,'linear');      % identity transformations   
021 %  x   = linspace(0,8); 
022 %  fnl = trraylpdf(x,'ac',gnl,0);  % with transformation 
023 %  fl  = trraylpdf(x,'ac',gl,0);   % without transformation 
024 %  empdistr(Ac), hold on 
025 %  pdfplot(fnl,11,'g'),  
026 %  pdfplot(fl,11,'r'),  hold off   
027 % 
028 % See also  wraylpdf 
029  
030 % Tested on : matlab 5.3 
031 % svi    10.11.1999 
032 % ir     24.05.2000 
033 % ir     25.06.2000 
034 % Revised pab  
035 % Added example   
036  
037  
038 % References: 
039 % Rychlik, I. and Leadbetter, M.R. (1997) 
040 % 'Analysis of ocean waves by crossing- and oscillation-intensities' 
041 % Proceedings of Seventh (1997) ISOPE Conference, Vol. III, pp. 206-213. 
042 % 
043  
044 x = x(:);   
045 f=createpdf; 
046  
047 if nargin<2|isempty(def) 
048   def='ac'; 
049 end 
050  
051 switch lower(def(2:end)) 
052  case  'c',               defnr = 1; 
053  case  't',               defnr =-1; 
054  case  'cat',             defnr = 2; 
055  otherwise, error('Unknown def') 
056 end 
057  
058 if  nargin<3|isempty(gn) 
059   gn=[(-5:0.02:5)' (-5:0.02:5)']; 
060 end 
061  
062 if nargin<4|isempty(utc) 
063   utc_d = gaus2dat([0 0],gn); % most frequent crossed level  
064   utc   = utc_d(1,2); 
065 end 
066  
067 if  nargin<1|isempty(x) 
068    if defnr<2    
069 %      xx=gaus2dat([ (0:0.1:5)' (0:0.1:5)'],gn); 
070 %      x=xx(:,2)-utc; 
071        ac=gaus2dat([0 5],gn); 
072        x=(linspace(utc,ac(1,2),100)-utc)'; 
073    else 
074 %      xx1=gaus2dat([ (0:0.05:5)' (0:0.05:5)'],gn); 
075 %      xx2=gaus2dat([ (0:0.05:5)' -(0:0.05:5)'],gn); 
076 %      x=xx1(:,2)-xx2(:,2); 
077        ac=gaus2dat([0 5],gn); 
078        at=gaus2dat([0 -5],gn); 
079        x=linspace(0,ac(1,2)-at(1,2),100)'; 
080    end 
081 end 
082  
083 h1=x; 
084 f.x={x}; 
085  
086 der1=ones(length(h1),1);der2=ones(length(h1),1); 
087  
088 if defnr==1 
089    hg1=tranproc([utc+h1 der1],gn);der1=abs(hg1(:,2)); 
090 %   f.f  = der1.*wraylpdf(hg1(:,1),1); 
091    f.f  = der1.*hg1(:,1).*exp(-0.5*hg1(:,1).^2); 
092 end 
093  
094 if defnr==-1 
095   hg2=tranproc([utc-h1 der2],gn);der2=abs(hg2(:,2)); 
096 %  f.f  = der2.*wraylpdf(-hg2(:,1),1); 
097    f.f  = -der2.*hg2(:,1).*exp(-0.5*hg2(:,1).^2); 
098 end  
099  
100 if defnr==2 
101   r=0:0.01:7; 
102   h11=gaus2dat([ones(length(r),1),r'],gn);%G(R) 
103   h22=gaus2dat([ones(length(r),1),-r'],gn);%G(-R) 
104                                              %new g transformation G(R)-G(-R) 
105   h=h11(:,2)-h22(:,2); 
106   Gs=[r' h];gs=fliplr(Gs); 
107                                              %derivative of g 
108   der=ones(length(r),1); 
109   hgs=tranproc([h der],gs); 
110   der=abs(hgs(:,2));  r2=abs(hgs(:,1)); 
111 %  ff=der.*wraylpdf(r2,1); 
112   ff  = der.*r2.*exp(-0.5*r2.^2); 
113   f.f  = interp1(h,ff,x,'linear'); 
114 end 
115  
116 switch lower(def) 
117  case  'ac' 
118   Htxt = ['Transformed Rayleigh approx. of Ac density']; 
119   xtxt = ['Ac [m]']; 
120  case  'at' 
121   Htxt = ['Transformed Rayleigh approx. of At density']; 
122   xtxt = ['At [m]']; 
123  case  'acat' 
124   Htxt = ['Transformed Rayleigh approx. of H=Ac+At density']; 
125   xtxt = ['H=Ac+At [m]']; 
126 end  
127    
128 f.title=Htxt; 
129 f.labx{1}=xtxt; 
130  
131  
132

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