Home > wafo > trgauss > private > wminmax.m

wminmax

PURPOSE ^

Calculates joint density of minimum and following maximum

SYNOPSIS ^

[f_mM, paramu] = wminmax(spec,nit,paramu,t)

DESCRIPTION ^

 WMINMAX Calculates joint density of minimum and following maximum 
         in a zero-mean stationary Gaussian with normalized spectrum spec 
  
  CALL:  f_mM   = wminmax(spec,nit,paramu,t);      
  
         f_mM  = joint density of minimum and following maximum in  X(t), 
                 for def=0 otherwise f_hh is the joint density of (H_1,H_2) 
                 that is heights of crest and trough in up-crossing waves. 
                  
         ALL THIS INPUTS NEEDS TO BE SET (NO DEFAULT VALUES ARE ALLOWED) 
     spec   = normalized spectrum L0=L2=1 
     nit    = order of numerical integration: 0,1,2,3,4,5. 
     paramu = parameter vector defining discretization of min/max values. 
     t      = grid of time points between maximum and minimum (to 
              integrate out). interval between maximum and the following 
              minimum,

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [f_mM, paramu] = wminmax(spec,nit,paramu,t) 
002 %WMINMAX Calculates joint density of minimum and following maximum 
003 %        in a zero-mean stationary Gaussian with normalized spectrum spec 
004 % 
005 % CALL:  f_mM   = wminmax(spec,nit,paramu,t);      
006 % 
007 %        f_mM  = joint density of minimum and following maximum in  X(t), 
008 %                for def=0 otherwise f_hh is the joint density of (H_1,H_2) 
009 %                that is heights of crest and trough in up-crossing waves. 
010 %                 
011 %        ALL THIS INPUTS NEEDS TO BE SET (NO DEFAULT VALUES ARE ALLOWED) 
012 %    spec   = normalized spectrum L0=L2=1 
013 %    nit    = order of numerical integration: 0,1,2,3,4,5. 
014 %    paramu = parameter vector defining discretization of min/max values. 
015 %    t      = grid of time points between maximum and minimum (to 
016 %             integrate out). interval between maximum and the following 
017 %             minimum, 
018    
019 %History 
020 % revised pab Dec2003 
021 % -  replaced code with call to spec2cov2 
022 paramv = paramu; 
023 par    = [paramu, paramv]; 
024  
025  
026 IAC = 1; 
027 ISQ = 0; 
028 EPS = 5e-5; 
029 EPSS = 1e-6; 
030 EPS0 = 1e-5; 
031 tol = [IAC,ISQ,EPS,EPSS,EPS0]; 
032 %tol=[1, 0, 5e-5, 1e-6, 1e-5]; 
033  
034 %g=[(-5:0.02:5)', (-5:0.02:5)'];  
035   
036 g = spec.tr; 
037  
038 if length(t)>101 
039   error('nr. of time points limited to 101.') 
040 end 
041  
042  
043 if abs(t(1))>0.00001  
044   error('t(1) < or > 0.') 
045 end 
046 if length(t) < 2 
047   error('nr. of wavelength <2.') 
048 end 
049  
050 if par(3)<1 
051   error('Require n>0.') 
052 end 
053 if par(6)<1 
054   error('Require n>0.') 
055 end 
056  
057 accur = [nit tol]; 
058  
059 dt    = t(2)-t(1); 
060 if 1, 
061   Nt = length(t)-1; 
062   nr = 4; 
063   R = spec2cov2(spec,nr,Nt,dt); 
064   cov = [t(:) R]; 
065 else 
066   S1 =specinterp(spec,dt); 
067   R = spec2cov(S1,4,400,4); 
068   cov = [R.t, R.R, R.Rt, R.Rtt,  R.Rttt, R.Rtttt]; 
069 end 
070  
071 writecov(cov,4); 
072  
073 if exist('t.in'), delete('t.in'), end 
074 if exist('transf.in'), delete('transf.in'), end 
075 if exist('accur.in'), delete('accur.in'), end 
076 if exist('Mm.in'), delete('Mm.in'), end 
077  
078 disp('   Writing data.') 
079 fid = fopen('t.in','wt'); 
080 fprintf(fid,'%8.5f\n',t); 
081 fclose(fid); 
082  
083 fid = fopen('accur.in','wt'); 
084 fprintf(fid,'%2.0f %2.0f %2.0f\n',accur(1:3)); 
085 fprintf(fid,'%8.7e %8.7e %8.7e\n',accur(4:6)); 
086 fclose(fid); 
087  
088 fid = fopen('transf.in','wt'); 
089 fprintf(fid,'%8.5e %8.5e \n',g'); 
090 fclose(fid); 
091  
092 fid=fopen('Mm.in','wt'); 
093 fprintf(fid,'%8.6e %8.6e %3.0f\n',par(1:3)); 
094 fprintf(fid,'%8.6e %8.6e %3.0f\n',par(4:6)); 
095 fclose(fid); 
096  
097 disp('   Starting Fortran executable.') 
098 dos([wafoexepath, 'minmax.exe']); 
099  
100 disp('   Loading data.') 
101 f_mM = loaddata('Maxmin.out'); 
102 f_mM = reshape(f_mM(:,3),paramv(3),paramu(3)); 
103 f_mM = rot90(f_mM,-2); 
104  
105  
106  
107  
108  
109

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