Home > wafo > cycles > res2arfc.m

res2arfc

PURPOSE ^

Calculates asymmetric rainflow cycles for a residual.

SYNOPSIS ^

[ARFC] = res2arfc(res,def,def_time)

DESCRIPTION ^

 RES2ARFC Calculates asymmetric rainflow cycles for a residual.
 
  CALL:   ARFC_res = res2arfc(res);
          ARFC_res = res2arfc(res,def,def_time);
 
  Output:
    ARFC_res = Asymmetric RFC for residual.             [N,2]/[N,4]
 
  Input:
    res      = Residual.                               [nres,1]/[nres,2]
    def      = 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.
 
  Example:
    x = load('sea.dat'); tp=dat2tp(x);
    [ARFC,res]=tp2arfc4p(tp);      % Default (min-to-Max cycles in residual)
    ARFC_res = res2arfc(res);      % Cycles in residual
    ccplot(ARFC), hold on, plot(ARFC_res(:,1),ARFC_res(:,2),'r.'), hold off
 
  See also  tp2arfc, tp2arfc4p, findrfc, dtp2arfm, tp2rfc, dat2tp, rfcfilt

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [ARFC] = res2arfc(res,def,def_time)
002 %RES2ARFC Calculates asymmetric rainflow cycles for a residual.
003 %
004 % CALL:   ARFC_res = res2arfc(res);
005 %         ARFC_res = res2arfc(res,def,def_time);
006 %
007 % Output:
008 %   ARFC_res = Asymmetric RFC for residual.             [N,2]/[N,4]
009 %
010 % Input:
011 %   res      = Residual.                               [nres,1]/[nres,2]
012 %   def      = Treatment of residual.
013 %              'up':   Count min-to-Max cycles,    (default)
014 %                      gives correct number of upcrossings.
015 %              'down': Count Max-to-min cycles, 
016 %                      gives correct number of downcrossings.
017 %              'CS':   Cloormann/Seeger method, 
018 %                      gives all closed hysterisis loops.
019 %                      This method is identical to the French AFNOR recommendation, 
020 %                      and the ASTM standard (variant called simplified version).
021 % def_time   = 0: Don't store time of max and min. (default)
022 %              1: Store the time when the maxima and minima occured.
023 %
024 % Example:
025 %   x = load('sea.dat'); tp=dat2tp(x);
026 %   [ARFC,res]=tp2arfc4p(tp);      % Default (min-to-Max cycles in residual)
027 %   ARFC_res = res2arfc(res);      % Cycles in residual
028 %   ccplot(ARFC), hold on, plot(ARFC_res(:,1),ARFC_res(:,2),'r.'), hold off
029 %
030 % See also  tp2arfc, tp2arfc4p, findrfc, dtp2arfm, tp2rfc, dat2tp, rfcfilt
031 
032 % Tested  on Matlab  5.3
033 %
034 % History:
035 % Created by PJ (Pär Johannesson) 25-Jul-2000
036 % Revised by PJ 09-Oct-2000
037 %   Some small corrections.
038 % Revised by PJ 04-Apr-2001
039 % - Added input def_time
040 % Correction by PJ 08-Nov-2001
041 %   Changed 
042 %     [ARFC,res_res] = tp2arfc4p(res2,def_time);
043 %   to
044 %     [ARFC,res_res] = tp2arfc4p(res2,[],def_time);
045 % Correction by PJ 13-Jun-2003
046 %   Exit funtion if less than two points in residual
047 
048 % Check input arguments
049 ni = nargin;
050 no = nargout;
051 error(nargchk(1,3,ni));
052 
053 if ni<2, def=[]; end
054 if ni<3, def_time = []; end
055 
056 % Default value
057 if isempty(def), def='up'; end
058 if isempty(def_time), def_time=0; end
059 
060 % Initiate
061 [nres,nn] = size(res);
062 
063 % Exit funtion if less than two points in residual
064 if nres<2
065     ARFC = [];
066     return
067 end
068 
069 % Count min-to-Max cycles, gives correct number of upcrossings
070 if strcmp(lower(def),'up')
071   if res(2,nn)-res(1,nn)>0 % First point is a minimum?
072     i_start=1;
073   else
074     i_start=2;
075   end
076     
077   I = i_start:2:nres-1;
078   if def_time == 0
079     ARFC = [res(I,nn) res(I+1,nn)];
080   else
081     ARFC = [res(I,2:nn) res(I+1,2:nn) res(I,1) res(I+1,1)];
082   end
083   
084 % Count Max-to-min cycles, gives correct number of downcrossings
085 elseif strcmp(lower(def),'down')
086   
087   if res(2,nn)-res(1,nn)>0 % First point is a minimum?
088     i_start=2;
089   else
090     i_start=1;
091   end
092   
093   I = i_start:2:nres-1;
094   if def_time == 0
095     ARFC = [res(I,nn) res(I+1,nn)];
096   else
097     ARFC = [res(I,2:nn) res(I+1,2:nn) res(I,1) res(I+1,1)];
098   end
099   
100 % Cloormann/Seeger, gives all closed hysterisis loops  
101 elseif strcmp(lower(def),'cs')
102   
103   res2 = [res;res];           % Concatenate two residuals
104   res2 = rfcfilter(res2,0,1); % Get turning points
105   [ARFC,res_res] = tp2arfc4p(res2,[],def_time);
106   
107 end
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