Home > wafo > wavemodels > mk87rnd.m

mk87rnd

PURPOSE ^

Random points from MK87 distribution of steepness and wave height.

SYNOPSIS ^

[h,ep] = mk87rnd(Hrms,Erms, N)

DESCRIPTION ^

 MK87RND Random points from MK87 distribution of steepness and wave height. 
  
  CALL:  [H E] = mk87rnd(Hrms,Erms,N ) 
  
   H,E        = two vectors of simulated data of length N 
   Hrms, Erms =  parameters of the MK87 distribution 
  
  Example: 
   Hs = 7;Tz=10;   
   Hrms = 0.715*Hs; 
   Erms = 0.0202+0.826*Hs/(Tz^2); 
   h = linspace(0,3*Hrms)'; s = linspace(0,5*Erms)'; 
   f = mk87pdf2(h,s,Hrms,Erms); 
   pdfplot(f) 
   [H E] = mk87rnd(Hrms,Erms,500); 
   hold on, plot(E,H,'.'), hold off 
  
  See also  mk87pdf, wweibrnd, wlogrnd

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

001 function [h,ep] = mk87rnd(Hrms,Erms, N) 
002 %MK87RND Random points from MK87 distribution of steepness and wave height. 
003 % 
004 % CALL:  [H E] = mk87rnd(Hrms,Erms,N ) 
005 % 
006 %  H,E        = two vectors of simulated data of length N 
007 %  Hrms, Erms =  parameters of the MK87 distribution 
008 % 
009 % Example: 
010 %  Hs = 7;Tz=10;   
011 %  Hrms = 0.715*Hs; 
012 %  Erms = 0.0202+0.826*Hs/(Tz^2); 
013 %  h = linspace(0,3*Hrms)'; s = linspace(0,5*Erms)'; 
014 %  f = mk87pdf2(h,s,Hrms,Erms); 
015 %  pdfplot(f) 
016 %  [H E] = mk87rnd(Hrms,Erms,500); 
017 %  hold on, plot(E,H,'.'), hold off 
018 % 
019 % See also  mk87pdf, wweibrnd, wlogrnd 
020  
021 %   References: 
022 %   Myrhaug, D. and Kjelsen S.P. (1987)  
023 %  'Prediction of occurences of steep and high waves in deep water'. 
024 %   Journal of waterway, Port, Coastal and Ocean Engineers, Vol. 113, pp 122--138 
025 % 
026 %   Myrhaug & Dahle (1984) Parametric modelling of joint probability 
027 %   density distributions for steepness and asymmetry in deep water  
028 %   waves 
029  
030 % tested on: matlab 5.1 
031 % history: 
032 % revised pab 01.04.2001 
033 % -added example 
034 % revised pab 04.11.2000 
035 % no dependence on stats toolbox anymore 
036 % by  Per A. Brodtkorb 19.11.1998 
037  
038  
039  
040 if nargin <  2  
041   error('Requires at least two input arguments.');  
042 end 
043    
044  
045 if nargin < 2|isempty(Erms), 
046   Erms=1; 
047 end 
048 if nargin < 1|isempty(Hrms), 
049   Hrms=1; 
050 end 
051 [errorcode Erms,Hrms] = comnsize(Erms,Hrms); 
052 if errorcode > 0 
053     error('Requires non-scalar arguments to match in size.'); 
054   end 
055 [n m]=size(Hrms); 
056 Hrms=Hrms(:);Erms=Erms(:); 
057   if nargin < 3, 
058   N=n*m;  
059 end 
060 h=zeros(N,1);ep=h; 
061    
062  
063  
064 % NB! weibpdf must be modified to correspond to 
065 % pdf=x^(b-1)/a^b*exp(-(x/a)^b) or else insert 
066 % weibpdf=2.39.*h.^1.39/(1.05^2.39).*exp(-(h./1.05).^2.39); 
067  
068 h=wweibrnd(1.05,2.39,N,1); 
069 sig=(-0.21*atan(2*(h-1.4))+0.325); 
070 ep=wlognrnd(my(h),sig).*Erms; 
071 h=h.*Hrms; 
072  
073 function y=my(h) 
074 y=zeros(size(h)); 
075 ind=(h <= 1.7); 
076 h1=h(ind); 
077 y(ind)=0.024-1.065.*h1+0.585.*h1.^2; 
078 %ind=find(h > 1.7); 
079 %h2=h(~ind); 
080 y(~ind)=0.32*atan(3.14*(h(~ind)-1.7))-0.096; 
081 return 
082

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