Home > wafo > cycles > dtp2arfm4p.m

dtp2arfm4p

PURPOSE ^

Calculates asymmetric RFM from discrete turning points (4-point).

SYNOPSIS ^

[RFM,res] = dtp2arfm4p(x,n,res0)

DESCRIPTION ^

 DTP2ARFM4P Calculates asymmetric RFM from discrete turning points (4-point).
 
  CALL:  [ARFM,res] = dtp2arfm4p(dtp,n);
         [ARFM,res] = dtp2arfm4p(dtp,n,res0);
 
  Output:
    ARFM  = Asymmetric RFM (without residual).       [n,n]
    res   = Residual.                               [nres,1]/[nres,1]
 
  Input:
    dtp   = Turning points (taking values 1,...,n). [T,1]/[T,2]
    n     = Number of levels.
    res0  = Residual (taking values 1,...,n).       [nres0,1]/[nres0,1]
 
  Example:
    x = load('sea.dat');                   % Load data
    [dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
    [ARFM,res] = dtp2arfm4p(dtp,32);    % Calculate asymmetric rainflow matrix
    cmatplot(u,u,ARFM,3), colorbar, res % Plot rainflow matrix
 
  See also  dtp2arfm, dtp2rfm, dcc2cmat, tp2rfc4p, dat2tp

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [RFM,res] = dtp2arfm4p(x,n,res0)
002 %DTP2ARFM4P Calculates asymmetric RFM from discrete turning points (4-point).
003 %
004 % CALL:  [ARFM,res] = dtp2arfm4p(dtp,n);
005 %        [ARFM,res] = dtp2arfm4p(dtp,n,res0);
006 %
007 % Output:
008 %   ARFM  = Asymmetric RFM (without residual).       [n,n]
009 %   res   = Residual.                               [nres,1]/[nres,1]
010 %
011 % Input:
012 %   dtp   = Turning points (taking values 1,...,n). [T,1]/[T,2]
013 %   n     = Number of levels.
014 %   res0  = Residual (taking values 1,...,n).       [nres0,1]/[nres0,1]
015 %
016 % Example:
017 %   x = load('sea.dat');                   % Load data
018 %   [dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
019 %   [ARFM,res] = dtp2arfm4p(dtp,32);    % Calculate asymmetric rainflow matrix
020 %   cmatplot(u,u,ARFM,3), colorbar, res % Plot rainflow matrix
021 %
022 % See also  dtp2arfm, dtp2rfm, dcc2cmat, tp2rfc4p, dat2tp
023 
024 % Tested  on Matlab  5.3
025 %
026 % History:
027 % Created by PJ (Pär Johannesson) 26-Jul-2000
028 %   Created from 'dtp2arfm'
029 
030 % Check input arguments
031 ni = nargin;
032 no = nargout;
033 error(nargchk(2,3,ni));
034 
035 if ni < 3
036   res0 = [];
037 end
038 
039 [T,nn] = size(x);
040 RFM = zeros(n);
041 
042 nres = length(res0);
043 res = zeros(2*n+1,nn);
044 if nres>0
045   res(1:nres,:) = res0;
046 end
047 
048 % Calculate ARFC and res
049 for i = 1:T
050   nres = nres+1;
051   res(nres,1:nn) = x(i,1:nn);
052   cycleFound = 1;
053   while cycleFound==1 & nres>=4
054     if res(nres-1,nn) < res(nres-2,nn)
055       A = [res(nres-1,nn) res(nres-2,nn)];
056     else
057       A = [res(nres-2,nn) res(nres-1,nn)];
058     end
059     if res(nres,nn) < res(nres-3,nn)
060       B = [res(nres,nn) res(nres-3,nn)];
061     else
062       B = [res(nres-3,nn) res(nres,nn)];
063     end
064     %A = sort([res(nres-1) res(nres-2)]);
065     %B = sort([res(nres) res(nres-3)]);
066     if A(1) >= B(1) & A(2) <= B(2)
067       RFM(res(nres-2,nn),res(nres-1,nn)) = RFM(res(nres-2,nn),res(nres-1,nn)) + 1;
068       res(nres-2,1:nn) = res(nres,1:nn);
069       nres = nres-2;
070     else
071       cycleFound = 0;
072     end
073   end
074 end
075 
076 % Residual
077 res = res(1:nres,:);
078 
079 
080

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