Home > wafo > cycles > cc2dcc.m

cc2dcc

PURPOSE ^

Discretize a cycle count.

SYNOPSIS ^

dcc = cc2dcc(param,cc,ddef)

DESCRIPTION ^

  CC2DCC Discretize a cycle count.
 
  CALL:  dcc = cc2dcc(param,cc,ddef);
 
         dcc   = a two column matrix with discrete classes.
         param = the parameter matrix.
         cc    = a two column matrix with the (continuous) cycle count.
         ddef  = 1 causes peaks to be projected upwards and troughs 
                   downwards to the closest discrete level (default).
               = 0 causes peaks and troughs to be projected to 
                   the closest discrete level.
               =-1 causes peaks to be projected downwards and the 
                   troughs upwards to the closest discrete level.
 
  See also  cc2cmat, dcc2cmat, dcc2cc

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function dcc = cc2dcc(param,cc,ddef)
002 % CC2DCC Discretize a cycle count.
003 %
004 % CALL:  dcc = cc2dcc(param,cc,ddef);
005 %
006 %        dcc   = a two column matrix with discrete classes.
007 %        param = the parameter matrix.
008 %        cc    = a two column matrix with the (continuous) cycle count.
009 %        ddef  = 1 causes peaks to be projected upwards and troughs 
010 %                  downwards to the closest discrete level (default).
011 %              = 0 causes peaks and troughs to be projected to 
012 %                  the closest discrete level.
013 %              =-1 causes peaks to be projected downwards and the 
014 %                  troughs upwards to the closest discrete level.
015 %
016 % See also  cc2cmat, dcc2cmat, dcc2cc
017 
018 % Tested  on Matlab  5.3
019 %
020 % History:
021 % Updated by PJ 28-Jul-2000
022 %   Now correct upper and lower limits of discretization.
023 % Created by PJ (Pär Johannesson) 01-Nov-1999
024 %   This is a new version of 'mkdisc' in WAT
025 
026 % Check input arguments
027 
028 ni = nargin;
029 no = nargout;
030 error(nargchk(2,3,ni));
031 
032 if ni<3 
033   ddef=[];
034 end 
035 
036 if isempty(ddef)
037   ddef = 1;
038 end
039 
040 dcc = cc;
041 
042 % Make so that minima is in first column
043 II = find(cc(:,1)>cc(:,2));
044 if ~isempty(II)
045   dcc(II,1) = cc(II,2);
046   dcc(II,2) = cc(II,1);
047 end
048 
049 % Make discretization
050 
051 a=param(1); b=param(2); n=param(3);
052 delta = (b-a)/(n-1);        % Discretization step
053 dcc = (dcc-a)/delta + 1;
054 
055 if ddef == 0
056   dcc = min(max(round(dcc),1),n);
057 elseif ddef == +1
058   dcc(:,1) = min(max(floor(dcc(:,1)),1),n-1);
059   dcc(:,2) = min(max(ceil(dcc(:,2)),2),n);
060 elseif ddef == -1
061   dcc(:,1) = min(max(ceil(dcc(:,1)),2),n);
062   dcc(:,2) = min(max(floor(dcc(:,2)),1),n-1);
063 else
064   error(['Undefined discretization definition, ddef = ' num2str(ddef)]);
065 end
066 
067 % 
068 if ~isempty(II)
069   dummy = dcc(II,1);
070   dcc(II,1) = dcc(II,2);
071   dcc(II,2) = dummy;
072 end
073

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