Home > wafo > cycles > dtp2rfm.m

# dtp2rfm

## PURPOSE

Calculates rainflow matrix from discrete turning points.

## SYNOPSIS

[RFM,RFM1,res] = dtp2rfm(x,varargin)

## DESCRIPTION

``` DTP2RFM Calculates rainflow matrix from discrete turning points.

CALL:            RFM = dtp2rfm(dtp,n)
[RFM,RFM1,res] = dtp2rfm(dtp,n,def)
[RFM,RFM1,res] = dtp2rfm(dtp,def,RFM0,res0)

Output:
RFM   = Rainflow matrix (residual included).    [n,n]
RFM1  = Rainflow matrix (without resudual).     [n,n]
res   = Residual.                               [nres,1]/[nres,2]

Input:
dtp   = Turning points (taking values 1,...,n). [T,1]/[T,2]
n     = Number of levels.
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).
RFM0  = Rainflow matrix (without resudual).     [n,n]
res0  = Residual (taking values 1,...,n).       [nres0,1]/[nres0,2]

Calculates the rainflow matrix (RFM) for the sequence of discrete turning
points,  by using the so-called 4-point algorithm.

It is possible to split the signal into smaller parts, and calculate
RFM 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 'RFM0' with residual 'res0':
[RFM1,RFM0,res0] = dtp2rfm(dtp(1:1000,:),32);    % Firts 1000 points
[RFM2] = dtp2rfm(dtp(1001:end,:),[],RFM0,res0);  % Point 1001 to end
This shall give the same result as (i.e. ARFM=ARFM2)
[RFM] = dtp2rfm(dtp,32);                         % Calculate all at once
sum(sum(RFM~=RFM2))                              % Shall return  0

Example:
[dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
RFM = dtp2rfm(dtp,32);                 % Calculate rainflow matrix
cmatplot(u,u,RFM,3), colorbar          % Plot rainflow matrix

## CROSS-REFERENCE INFORMATION

This function calls:
 dtp2arfm Calculates asymmetric RFM from discrete turning points. error Display message and abort function. triu Extract upper triangular part.
This function is called by:
 Chapter4 % CHAPTER4 contains the commands used in Chapter 4 of the tutorial dat2rfm Calculates the rainflow matrix from a time signal. itmkurs_lab2 Script to computer exercises 2 itmkurs_lab4 Script to computer exercises 4 rfc2load_fat Recontructs a load process given the frequency matrix (and residual). smctpsim Simulates a switching Markov chain of turning points, test_cycles Quick test of the routines in module 'cycles' test_markov Quick test of the routines in module 'markov'

## SOURCE CODE

```001 function [RFM,RFM1,res] = dtp2rfm(x,varargin)
002 %DTP2RFM Calculates rainflow matrix from discrete turning points.
003 %
004 % CALL:            RFM = dtp2rfm(dtp,n)
005 %       [RFM,RFM1,res] = dtp2rfm(dtp,n,def)
006 %       [RFM,RFM1,res] = dtp2rfm(dtp,def,RFM0,res0)
007 %
008 % Output:
009 %   RFM   = Rainflow matrix (residual included).    [n,n]
010 %   RFM1  = Rainflow matrix (without resudual).     [n,n]
011 %   res   = Residual.                               [nres,1]/[nres,2]
012 %
013 % Input:
014 %   dtp   = Turning points (taking values 1,...,n). [T,1]/[T,2]
015 %   n     = Number of levels.
016 %   def   = Treatment of residual.
017 %           'up':   Count min-to-Max cycles,    (default)
018 %                   gives correct number of upcrossings.
019 %           'down': Count Max-to-min cycles,
020 %                   gives correct number of downcrossings.
021 %           'CS':   Cloormann/Seeger method,
022 %                   gives all closed hysterisis loops.
023 %                   This method is identical to the French AFNOR recommendation,
024 %                   and the ASTM standard (variant called simplified version).
025 %   RFM0  = Rainflow matrix (without resudual).     [n,n]
026 %   res0  = Residual (taking values 1,...,n).       [nres0,1]/[nres0,2]
027 %
028 % Calculates the rainflow matrix (RFM) for the sequence of discrete turning
029 % points,  by using the so-called 4-point algorithm.
030 %
031 % It is possible to split the signal into smaller parts, and calculate
032 % RFM part by part. It can be especially useful for long signals.
033 % We count the first part and for the second part we continue counting
034 % from previously counted 'RFM0' with residual 'res0':
035 %   [RFM1,RFM0,res0] = dtp2rfm(dtp(1:1000,:),32);    % Firts 1000 points
036 %   [RFM2] = dtp2rfm(dtp(1001:end,:),[],RFM0,res0);  % Point 1001 to end
037 % This shall give the same result as (i.e. ARFM=ARFM2)
038 %   [RFM] = dtp2rfm(dtp,32);                         % Calculate all at once
039 %   sum(sum(RFM~=RFM2))                              % Shall return  0
040 %
041 % Example:
043 %   [dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
044 %   RFM = dtp2rfm(dtp,32);                 % Calculate rainflow matrix
045 %   cmatplot(u,u,RFM,3), colorbar          % Plot rainflow matrix
046 %
048
049 % Tested  on Matlab  5.3
050 %
051 % History:
052 % Revised by PJ 26-Jul-2000
053 %   New input 'def'.
054 %   Now supports AFNOR and ASTM standards for rainflow counting.
055 % Revised by PJ (Pär Johannesson) 12-Jan-2000
056 %   updated for WAFO
057 % Created by PJ (Pär Johannesson) 1999
058
059 % Check input arguments
060 ni = nargin;
061 no = nargout;
062 error(nargchk(2,4,ni));
063
064 % Calculate asymetric RFM
065 if no < 2
066   RFM = dtp2arfm(x,varargin{:});
067 else
068   [RFM,RFM1,res] = dtp2arfm(x,varargin{:});
069 end
070
071 % Convert to symetric rainflow
072 RFM = RFM+RFM';
073 RFM = triu(RFM);
074 if no >= 2
075   RFM1 = RFM1+RFM1';
076   RFM1 = triu(RFM1);
077 end
078
079```

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