Home > wafo > cycles > tp2mm.m

tp2mm

PURPOSE ^

Calculates min2Max and Max2min cycles from a sequence of turning points

SYNOPSIS ^

[mM,Mm] = tp2mm(tp)

DESCRIPTION ^

  TP2MM Calculates min2Max and Max2min cycles from a sequence of turning points
 
  CALL:  [mM,Mm] = tp2mm(TP);
 
    mM  = a two column matrix with the min2Max count.
    Mm  = a two column matrix with the Max2min count.
    TP  = a two column matrix with the sequence of turning points.
 
  Example:
    TP = dat2tp(x);
    [mM,Mm] = tp2mm(TP);
    ccplot(mM);
 
  See also  dat2tp, cc2cmat, ccplot

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [mM,Mm] = tp2mm(tp)
002 % TP2MM Calculates min2Max and Max2min cycles from a sequence of turning points
003 %
004 % CALL:  [mM,Mm] = tp2mm(TP);
005 %
006 %   mM  = a two column matrix with the min2Max count.
007 %   Mm  = a two column matrix with the Max2min count.
008 %   TP  = a two column matrix with the sequence of turning points.
009 %
010 % Example:
011 %   TP = dat2tp(x);
012 %   [mM,Mm] = tp2mm(TP);
013 %   ccplot(mM);
014 %
015 % See also  dat2tp, cc2cmat, ccplot
016 
017 % Tested  on Matlab  5.3
018 %
019 % History:
020 % Updated by PJ 19-Oct-2000
021 %   Two versions existed (in 'onedim' and 'cycles')!
022 %   Removed version in 'onedim'
023 %   Now handles vectors
024 % Revised by PJ (Pär Johannesson) 01-Nov-1999
025 %   updated for WAFO
026 % Copied from WAT Ver. 1.2
027 
028 [n m]= size(tp);
029 if n<m
030   b=m;m=n;n=b; 
031   tp=tp';
032 end
033 
034 if n<2, 
035   error('The vector must have more than 1 elements!')
036 end
037 
038 switch m
039   case {1, 2},  % dimension OK!
040   otherwise, 
041     error('Wrong dimension of input! dim must be 2xN, 1xN, Nx2 or Nx1 ')
042 end
043 
044 if tp(1,m)>tp(2,m)
045   im = 2;
046   iM = 1;
047 else
048   im = 1;
049   iM = 2;
050 end
051 
052 % Delete first point if it is a maximum
053 %if tp(1,m)>tp(2,m)
054 %  tp = tp(2:n,:);
055 %  if tp(1,m)>tp(2,m)
056 %    error('tp  is not a sequence of turning points.')
057 %  end
058 %end
059 
060 % Count min-max and max-min cycles
061 n=length(tp);
062 mM=[tp(im:2:n-1,m) tp(im+1:2:n,m)]; % min-max cycles
063 Mm=[tp(iM:2:n-1,m) tp(iM+1:2:n,m)]; % max-min cycles
064 
065 
066 
067

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