Home > wafo > cycles > dat2rfm.m

dat2rfm

PURPOSE ^

Calculates the rainflow matrix from a time signal.

SYNOPSIS ^

[RFM,u,param] = dat2rfm(x,h,n)

DESCRIPTION ^

 DAT2RFM  Calculates the rainflow matrix from a time signal. 
  
  CALL:  RFM = dat2rfm(x) 
         [RFM,u,param] = dat2rfm(x,h,n) 
  
  Input: 
    x   = Time signal.                          [N,1]/[N,2] 
    h   = Threshold range for rainflow filter. (default: 0) 
    n   = Number of discretization levels.     (default: 64)  
          OR paramter matrix [a b n]. 
  
  Output: 
    RFM   = Rainflow matrix                       [N,N] 
    u     = Discrete levels.                      [n,1] 
    param = the parameter matrix  [a b n]. 
  
  Example: 
    x=load('sea.dat'); 
    [RFM,u] = dat2rfm(x);    % Default parameters 
    subplot(1,2,1), cmatplot(u,u,RFM,3) 
    [RFM,u] = dat2rfm(x,0.5,[-2.5 2.5 50]); 
    subplot(1,2,2), cmatplot(u,u,RFM,3) 
  
  See also  rfcfilter, dat2dtp, dtp2frm

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [RFM,u,param] = dat2rfm(x,h,n) 
002  
003 %DAT2RFM  Calculates the rainflow matrix from a time signal. 
004 % 
005 % CALL:  RFM = dat2rfm(x) 
006 %        [RFM,u,param] = dat2rfm(x,h,n) 
007 % 
008 % Input: 
009 %   x   = Time signal.                          [N,1]/[N,2] 
010 %   h   = Threshold range for rainflow filter. (default: 0) 
011 %   n   = Number of discretization levels.     (default: 64)  
012 %         OR paramter matrix [a b n]. 
013 % 
014 % Output: 
015 %   RFM   = Rainflow matrix                       [N,N] 
016 %   u     = Discrete levels.                      [n,1] 
017 %   param = the parameter matrix  [a b n]. 
018 % 
019 % Example: 
020 %   x=load('sea.dat'); 
021 %   [RFM,u] = dat2rfm(x);    % Default parameters 
022 %   subplot(1,2,1), cmatplot(u,u,RFM,3) 
023 %   [RFM,u] = dat2rfm(x,0.5,[-2.5 2.5 50]); 
024 %   subplot(1,2,2), cmatplot(u,u,RFM,3) 
025 % 
026 % See also  rfcfilter, dat2dtp, dtp2frm 
027  
028 % Copyright (c) 2003 by Pär Johannesson 
029  
030 % Tested  on Matlab  6.5 
031 % 
032 % History: 
033 % Created by PJ (Pär Johannesson) 10-Apr-2003 
034 % Updated by PJ 03-Jun-2003 
035  
036 %%%% 
037 % Compile to MEX 
038 % 
039 % mcc -x ts2rfm 
040  
041 %%%% 
042 % Check input arguments 
043  
044 ni = nargin; 
045 no = nargout; 
046 error(nargchk(1,3,ni)); 
047  
048 if ni<2, h=[]; end 
049 if ni<3, n=[]; end 
050  
051 %%%% 
052 % Default settings 
053  
054 if isempty(h), h=0; end 
055 if isempty(n), n=64; end 
056  
057 if h<0, h=0; end 
058  
059 x = x(:,end);  % Data values in last column (skip time in 1st column) 
060  
061 %%%% 
062 % Get Turning Points (TP) 
063 % and  
064 % Rainflow filter signal 
065  
066 if h==0 
067     tp = rfcfilter(x,0,1);  % Get TP 
068 else 
069     tp = rfcfilter(x,h);    % Get TP & RFC-filter 
070 end 
071  
072 %%%% 
073 % Discretization 
074  
075 if length(n)==3 
076     param = n; 
077     n=param(3); 
078 else 
079      
080     u_min = min(tp); 
081     u_max = max(tp); 
082      
083     param = [u_min u_max n]; 
084 end 
085  
086 u = levels(param);  % Discrete levels 
087  
088 %%%% 
089 % Get discrete TP 
090  
091 [dtp,u] = dat2dtp(param,tp,h,0); 
092  
093 %%%% 
094 % Calculate RFM 
095  
096 RFM = dtp2rfm(dtp,n,'CS');

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