TRANPROC Transforms process X and up to four derivatives using the transformation f. CALL: y = tranproc(x,f); x = input data matrix with 1+N columns, [X X1 ... XN], where Xi is the i'th time derivative of X. 0<=N<=4. f = [x,f(x)], transform function, y = f(x). y = output data matrix with 1+N columns, [Y Y1 ...YN], of transformed data, where Y = f(X) and Yi is the i'th time derivative of Y = f(X). By the basic rules of derivation: Y1 = f'(X)*X1 Y2 = f''(X)*X1^2 + f'(X)*X2 Y3 = f'''(X)*X1^3 + f'(X)*X3 + 3*f''(X)*X1*X2 Y4 = f''''(X)*X1^4 + f'(X)*X4 + 6*f'''(X)*X1^2*X2 + f''(X)*(3*X2^2 + 4*X1*X3) The derivation of f is performed numerically with a central difference method with linear extrapolation towards the beginning and end of f, respectively. Example: % Derivative of g and the transformed Gaussian model. x = linspace(-6,6,501)'; g = hermitetr(x); gder = tranproc([g(:,1) ones(size(g,1),1)],g); gder(:,1) = g(:,1); plot(g(:,1),[g(:,2),gder(:,2)]) plot(g(:,1),wnormpdf(g(:,2)).*gder(:,2),g(:,1),wnormpdf(g(:,1))) legend('Transformed model','Gaussian model') See also trangood.
Makes a transformation that is suitable for efficient transforms. | |
Transforms process X and up to four derivatives | |
Difference and approximate derivative. | |
Display message and abort function. | |
Display warning message; disable or enable warning messages. |
Cavanie et al. (1976) approximation of the density (Tc,Ac) | |
% CHAPTER3 Demonstrates distributions of wave characteristics | |
Simulates a Gaussian process and its derivative | |
Transforms x using the transformation g. | |
Estimate one-sided spectral density from data. | |
Transforms xx using the inverse of transformation g. | |
Kernel Density Estimator. | |
Binned Kernel Density Estimator. | |
Kernel Density Estimator. | |
Simulates process with given irregularity factor and crossing spectrum | |
Longuet-Higgins (1983) approximation of the density (Tc,Ac) | |
Calculates quantile levels which encloses P% of PDF | |
reconstruct the spurious/missing points of timeseries | |
Spectral simulation of a Gaussian sea, 2D (x,t) or 3D (x,y,t) | |
Evaluates survival function R(h1,h2)=P(Ac>h1,At>h2). | |
Evaluates cdf of crests P(Ac<=h) or troughs P(At<=h). | |
Joint intensity matrix for cycles (max,min)-, rainflow- and (crest,trough) | |
Calculates joint density of Maximum, minimum and period. | |
Simulates a Gaussian process and its derivative from spectrum | |
Evaluates densities of wave period Tcc, wave lenght Lcc. | |
Joint density of amplitude and period/wave-length characteristics | |
Evaluates densities for crest-,trough-period, length. | |
Random sampling from a smoothed empirical distribution | |
Transform joint T-H density to V-H density | |
Transforms process X and up to four derivatives | |
Calculates transformed Rayleigh approximation for amplitudes | |
Joint distribution (pdf) of crest front velocity and wave height: |
001 function y = tranproctranproc(x,ff) 002 %TRANPROC Transforms process X and up to four derivatives 003 % using the transformation f. 004 % 005 % CALL: y = tranproc(x,f); 006 % 007 % x = input data matrix with 1+N columns, [X X1 ... XN], where 008 % Xi is the i'th time derivative of X. 0<=N<=4. 009 % f = [x,f(x)], transform function, y = f(x). 010 % y = output data matrix with 1+N columns, [Y Y1 ...YN], of 011 % transformed data, where Y = f(X) and Yi is the i'th time 012 % derivative of Y = f(X). 013 % 014 % By the basic rules of derivation: 015 % Y1 = f'(X)*X1 016 % Y2 = f''(X)*X1^2 + f'(X)*X2 017 % Y3 = f'''(X)*X1^3 + f'(X)*X3 + 3*f''(X)*X1*X2 018 % Y4 = f''''(X)*X1^4 + f'(X)*X4 + 6*f'''(X)*X1^2*X2 019 % + f''(X)*(3*X2^2 + 4*X1*X3) 020 % 021 % The derivation of f is performed numerically with a central difference 022 % method with linear extrapolation towards the beginning and end of f, 023 % respectively. 024 % 025 % Example: % Derivative of g and the transformed Gaussian model. 026 % x = linspace(-6,6,501)'; 027 % g = hermitetr(x); 028 % gder = tranproc([g(:,1) ones(size(g,1),1)],g); 029 % gder(:,1) = g(:,1); 030 % plot(g(:,1),[g(:,2),gder(:,2)]) 031 % plot(g(:,1),wnormpdf(g(:,2)).*gder(:,2),g(:,1),wnormpdf(g(:,1))) 032 % legend('Transformed model','Gaussian model') 033 % 034 % See also trangood. 035 036 % Tested on: matlab 5.1 037 % history: 038 % revised pab 09.01.2001 039 % -added check on hn to make sure the spacing is not too dense 040 % -added nmax 041 % -updated help header 042 % by ??? 043 044 error(nargchk(2,2,nargin)) 045 046 N = size(x,2)-1; % N = number of derivatives 047 nmax = ceil((max(ff(:,1))-min(ff(:,1)))*10^(7/max(N,1))); 048 f = trangood(ff,size(ff,1),min(x(:,1)),max(x(:,1)),nmax); 049 050 n = size(f,1); 051 y = x; 052 xu = 1+(n-1)*(x(:,1)-f(1,1))/(f(n,1)-f(1,1)); 053 054 fi = floor(xu); 055 056 i = find(fi==n); 057 fi(i) = fi(i)-1; 058 059 xu = xu-fi; 060 y(:,1) = f(fi,2)+(f(fi+1,2)-f(fi,2)).*xu; 061 062 063 if N>0 064 hn = f(2,1)-f(1,1); 065 if hn^N<sqrt(eps) 066 disp('Numerical problems may occur for the derivatives in tranproc.') 067 warning('The sampling of the transformation may be too small.') 068 end 069 % Transform X with the derivatives of f. 070 fxder = zeros(size(x,1),N); 071 fder = f; 072 for k=1:N, % Derivation of f(x) using a difference method. 073 n = size(fder,1); 074 %fder = [(fder(1:n-1,1)+fder(2:n,1))/2 diff(fder(:,2))./diff(fder(:,1))]; 075 fder = [(fder(1:n-1,1)+fder(2:n,1))/2 diff(fder(:,2))/hn]; 076 fxder(:,k) = tranproc(x(:,1),fder); 077 end; 078 %(-fder(ix+2,2)+8*fder(ix+1,2) - ... 079 % 8*fder(ix-1,2)+fder(ix-2,2))./(12*hn); 080 % Calculate the transforms of the derivatives of X. 081 % First time derivative of y: y1 = f'(x)*x1 082 y(:,1+1)=fxder(:,1).*x(:,1+1); 083 if N>1 084 % Second time derivative of y: 085 % y2 = f''(x)*x1.^2+f'(x)*x2 086 y(:,1+2)=fxder(:,2).*x(:,1+1).^2 + fxder(:,1).*x(:,1+2); 087 if N>2 088 % Third time derivative of y: 089 % y3 = f'''(x)*x1.^3+f'(x)*x3 +3*f''(x)*x1*x2 090 y(:,1+3)=fxder(:,3).*x(:,1+1).^3 + fxder(:,1).*x(:,1+3) + ... 091 3*fxder(:,2).*x(:,1+1).*x(:,1+2); 092 if N>3 093 % Fourth time derivative of y: 094 % y4 = f''''(x)*x1.^4+f'(x)*x4 095 % +6*f'''(x)*x1^2*x2+f''(x)*(3*x2^2+4x1*x3) 096 y(:,1+4)=fxder(:,4).*x(:,1+1).^4 + fxder(:,1).*x(:,1+4) + ... 097 6*fxder(:,3).*x(:,1+1).^2.*x(:,1+2) + ... 098 fxder(:,2).*(3*x(:,1+2).^2+4*x(:,1+1).*x(:,1+3)); 099 if N>4 100 warning(['Transformation of derivatives of order>4 not supported' ... 101 ' in tranproc.']) 102 end 103 end 104 end 105 end 106 end 107 108 109 110
Comments or corrections to the WAFO group