Home > wafo > cycles > cc2lc.m

cc2lc

PURPOSE ^

Calculates the number of upcrossings from a cycle count

SYNOPSIS ^

d = cc2lc(cc,def,plotflag,sa)

DESCRIPTION ^

 CC2LC Calculates the number of upcrossings from a cycle count  
 
  CALL:  lc = cc2lc(cc,def,plotflag,sa);
 
       lc = a two column matrix with levels and number of upcrossings.
       cc = cycle count (possibly rainflow filtered).
 
      def = 1, only upcrossings.
            2, upcrossings and maxima (default).
            3, upcrossings, minima, and maxima.
            4, upcrossings and minima.
 
 plotflag = 0, no plotting.
            1, plot the number of upcrossings overplotted
               with Rice formula for the crossing intensity
               for a Gaussian process (default).
            
 
      sa  = standard deviation of the process.
            (Default estimates it from the number of upcrossings)
 
  Calculates the number of upcrossings from a cycle count, e.g.
  min2Max cycles or rainflow cycles.
 
  Example:
    mM = tp2mm(tp);
    lc = cc2lc(mM);
 
  See also  lcplot, tp2lc

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function d = cc2lc(cc,def,plotflag,sa)
002 %CC2LC Calculates the number of upcrossings from a cycle count  
003 %
004 % CALL:  lc = cc2lc(cc,def,plotflag,sa);
005 %
006 %      lc = a two column matrix with levels and number of upcrossings.
007 %      cc = cycle count (possibly rainflow filtered).
008 %
009 %     def = 1, only upcrossings.
010 %           2, upcrossings and maxima (default).
011 %           3, upcrossings, minima, and maxima.
012 %           4, upcrossings and minima.
013 %
014 %plotflag = 0, no plotting.
015 %           1, plot the number of upcrossings overplotted
016 %              with Rice formula for the crossing intensity
017 %              for a Gaussian process (default).
018 %           
019 %
020 %     sa  = standard deviation of the process.
021 %           (Default estimates it from the number of upcrossings)
022 %
023 % Calculates the number of upcrossings from a cycle count, e.g.
024 % min2Max cycles or rainflow cycles.
025 %
026 % Example:
027 %   mM = tp2mm(tp);
028 %   lc = cc2lc(mM);
029 %
030 % See also  lcplot, tp2lc
031 
032 % NB! needs normpdf to be able to overplot Rice formula
033 
034 % Tested on: matlab 5.3
035 % History:
036 % revised by PJ 09-Jan-2000
037 %   copy of mm2lc
038 % revised by pab 11.08.99
039 %   changed name from mm2cross to mm2lc
040 % revised by Per A. Brodtkorb 01.10.98
041 %   added: overplot the crossingspectrum with Rice formula for crossing  
042 %   intensity for a Gaussian process
043 
044 
045 
046 if nargin<4
047   sa=[]; % unknown stdev is default
048 end
049 
050 if nargin<3|isempty(plotflag)
051   plotflag=1; %default
052 end
053 if nargin<2|isempty(def)
054  def=2; % default
055 end
056 
057 if ((def<1) | (def>4))
058   error('def must be one of (1,2,3,4).')
059 end
060 
061 index=find(cc(:,1) <= cc(:,2));
062 
063 if isempty(index)
064   error('Error in input cc.')
065 end
066 
067 cc=cc(index,:);
068 ncc=length(cc);
069 
070 minima=[cc(:,1)  ones(ncc,1) zeros(ncc,1) ones(ncc,1)];
071 maxima=[cc(:,2) -ones(ncc,1) ones(ncc,1) zeros(ncc,1)];
072 
073 extremes=[maxima; minima];
074 [temp index]=sort(extremes(:,1));
075 extremes=extremes(index,:);
076 
077 ii=1;
078 n=length(extremes);
079 extr=zeros(n,4);
080 extr(1,:)=extremes(1,:);
081 for i=2:n
082   if extremes(i,1)==extr(ii,1);
083     extr(ii,2:4)=extr(ii,2:4)+extremes(i,2:4);
084   else
085     ii=ii+1;
086     extr(ii,:)=extremes(i,:);
087   end
088 end
089 [xx nx]=max(extr(:,1));
090 
091 if def==4 % This are upcrossings + minima
092   d=[extr(1:nx,1) cumsum(extr(1:nx,2))];
093   d(nx,2)=d(nx-1,2);
094 end
095 
096 if def==1 % This are only upcrossings
097   d=[extr(1:nx,1) cumsum(extr(1:nx,2)) - extr(1:nx,4)];
098 end
099 
100 if def==3 % This are upcrossings + minima + maxima
101   d=[extr(1:nx,1) cumsum(extr(1:nx,2)) + extr(1:nx,3)];
102 end
103 
104 if def==2 % This are upcrossings + maxima
105   d=[extr(1:nx,1) cumsum(extr(1:nx,2)) + extr(1:nx,3)-extr(1:nx,4)];
106 end
107 
108 %% Plots are made by lcplot
109 
110 if plotflag  
111   lcplot(d,2,0,sa);
112 end
113 
114

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