Home > wafo > cycles > tp2arfc.m

tp2arfc

PURPOSE ^

Calculates asymmetric rainflow cycles from turning points.

SYNOPSIS ^

[ARFC,ARFC1,res,def] = tp2arfc(x,def,ARFC0,res0)

DESCRIPTION ^

 TP2ARFC Calculates asymmetric rainflow cycles from turning points.
 
  CALL:  [ARFC,ARFC1,res] = tp2arfc(tp,def,ARFC0,res0);
                     ARFC = tp2arfc(tp);
 
  Output:
    ARFC    = Asymetric RFC (residual included).      [N,2]/[N,4]
    ARFC1   = Asymetric RFC (without resudual).       [N1,2]/[N1,4]
    res     = Residual.                               [nres,1]/[nres,2]
 
  Input:
    tp       = Turning points.                         [T,1]/[T,2]
    def      = Choice of definition of rainflow cycles   [struct array]
    def.res  = Treatment of residual.
               'up':   Count min-to-Max cycles,    (default)
                       gives correct number of upcrossings.
               'down': Count Max-to-min cycles, 
                       gives correct number of downcrossings.
               'CS':   Cloormann/Seeger method, 
                       gives all closed hysterisis loops.
                       This method is identical to the French AFNOR recommendation, 
                       and the ASTM standard (variant called simplified version).
    def.time = 0: Don't store time of max and min. (default)
               1: Store the time when the maxima and minima occured.
    ARFC0    = Asymetric RFC (without resudual).       [N0,2]/[N0,4]
    res0     = Residual.                               [nres0,1]/[nres0,2]
 
  Calculates the asymmetric rainflow cycles (ARFC) for the sequence of 
  turning points,  by using the so-called 4-point algorithm.
 
  It is possible to split the signal into smaller parts, and calculate 
  ARFC part by part. It can be especially useful for long signals.
  We count the first part and for the second part we continue counting 
  from previously counted 'ARFC0' with residual 'res0':
    [ARFC1,ARFC0,res0] = tp2arfc(tp(1:1000,:));      % Firts 1000 points
    [ARFC2] = tp2arfc(tp(1001:end,:),[],ARFC0,res0); % Point 1001 to end
  This shall give the same result as (i.e. ARFC=ARFC2)
    [ARFC] = tp2arfc(tp);                            % Calculate all at once
    sum(ARFC~=ARFC2)                                 % Shall return  [0 0]
 
  This routine doesn't use MEX, Fortran or C codes, only matlab code.
 
  Example:
    x = load('sea.dat'); tp=dat2tp(x);
    ARFC=tp2arfc(tp);      % Default (min-to-Max cycles in residual)
    ccplot(ARFC) 
 
  See also  tp2arfc4p, findrfc, dtp2arfm, tp2rfc, tp2mm, dat2tp, rfcfilt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [ARFC,ARFC1,res,def] = tp2arfc(x,def,ARFC0,res0)
002 %TP2ARFC Calculates asymmetric rainflow cycles from turning points.
003 %
004 % CALL:  [ARFC,ARFC1,res] = tp2arfc(tp,def,ARFC0,res0);
005 %                    ARFC = tp2arfc(tp);
006 %
007 % Output:
008 %   ARFC    = Asymetric RFC (residual included).      [N,2]/[N,4]
009 %   ARFC1   = Asymetric RFC (without resudual).       [N1,2]/[N1,4]
010 %   res     = Residual.                               [nres,1]/[nres,2]
011 %
012 % Input:
013 %   tp       = Turning points.                         [T,1]/[T,2]
014 %   def      = Choice of definition of rainflow cycles   [struct array]
015 %   def.res  = Treatment of residual.
016 %              'up':   Count min-to-Max cycles,    (default)
017 %                      gives correct number of upcrossings.
018 %              'down': Count Max-to-min cycles, 
019 %                      gives correct number of downcrossings.
020 %              'CS':   Cloormann/Seeger method, 
021 %                      gives all closed hysterisis loops.
022 %                      This method is identical to the French AFNOR recommendation, 
023 %                      and the ASTM standard (variant called simplified version).
024 %   def.time = 0: Don't store time of max and min. (default)
025 %              1: Store the time when the maxima and minima occured.
026 %   ARFC0    = Asymetric RFC (without resudual).       [N0,2]/[N0,4]
027 %   res0     = Residual.                               [nres0,1]/[nres0,2]
028 %
029 % Calculates the asymmetric rainflow cycles (ARFC) for the sequence of 
030 % turning points,  by using the so-called 4-point algorithm.
031 %
032 % It is possible to split the signal into smaller parts, and calculate 
033 % ARFC part by part. It can be especially useful for long signals.
034 % We count the first part and for the second part we continue counting 
035 % from previously counted 'ARFC0' with residual 'res0':
036 %   [ARFC1,ARFC0,res0] = tp2arfc(tp(1:1000,:));      % Firts 1000 points
037 %   [ARFC2] = tp2arfc(tp(1001:end,:),[],ARFC0,res0); % Point 1001 to end
038 % This shall give the same result as (i.e. ARFC=ARFC2)
039 %   [ARFC] = tp2arfc(tp);                            % Calculate all at once
040 %   sum(ARFC~=ARFC2)                                 % Shall return  [0 0]
041 %
042 % This routine doesn't use MEX, Fortran or C codes, only matlab code.
043 %
044 % Example:
045 %   x = load('sea.dat'); tp=dat2tp(x);
046 %   ARFC=tp2arfc(tp);      % Default (min-to-Max cycles in residual)
047 %   ccplot(ARFC) 
048 %
049 % See also  tp2arfc4p, findrfc, dtp2arfm, tp2rfc, tp2mm, dat2tp, rfcfilt
050 
051 % Tested  on Matlab  5.3
052 %
053 % History:
054 % Revised by PJ 06-Jul-2005
055 %   Fixed error with def & mod to avoid warning i R14SP2.
056 % Revised by PJ 26-Jul-2000
057 %   New format of def.
058 % Revised by PJ 12-Jul-2000
059 %   Now calls 'tp2arfc4p' to calculate ARFC0 and res.
060 %   Input 'def_res'.
061 %   Now supports AFNOR and ASTM standards for rainflow counting.
062 % Revised by PJ 18-May-2000
063 %   updated help text.
064 % Revised by PJ 09-Jan-2000
065 %   updated for WAFO
066 % Created by PJ (Pär Johannesson) 1999
067 
068 % Check input arguments
069 ni = nargin;
070 no = nargout;
071 error(nargchk(1,4,ni));
072  
073 [T,nn] = size(x);
074 
075 if ni<2, def = [];   end
076 if ni<3, ARFC0 = []; end
077 if ni<4, res0 = [];  end
078 
079 def0=def;
080 if ~isempty(def)
081   if isnumeric(def)
082     def=[]; def.time = def0;
083   elseif ischar(def)
084     def=[]; def.res = def0;
085   elseif ~isstruct(def)
086     def=[];
087   end
088 end
089 
090 % Set default values
091 if ~isfield(def,'res')
092   def.res = 'up';
093 end
094 if ~isfield(def,'time')
095   def.time = 0;
096 end
097 
098 % Calculate ARFC0 and res
099 if def.time == 0
100   [ARFC,res] = tp2arfc4p(x(:,1:nn),res0,def.time);
101 else
102   if nn==1
103     [ARFC,res] = tp2arfc4p([(1:T)' x(:)],res0,def.time);
104   else
105     [ARFC,res] = tp2arfc4p(x,res0,def.time);
106   end
107 end
108 
109 % Add previously counted cycles (if any)
110 if ~isempty(ARFC0)
111   ARFC = [ARFC0; ARFC];
112 end
113 
114 % Rainflow cycles without residual
115 if no>=2, ARFC1=ARFC; end
116 
117 % Rainflow cycles plus cycles in residual
118 % ARFC = ARFC + 'cycles in res'
119 ARFC_res = res2arfc(res,def.res,def.time); % Treat residual
120 ARFC = [ARFC; ARFC_res];
121 
122 
123

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