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
Display message and abort function. |
% CHAPTER3 Demonstrates distributions of wave characteristics | |
% CHAPTER4 contains the commands used in Chapter 4 of the tutorial | |
Estimate transformation, g, from data. | |
Script to computer exercises 1 | |
Script to computer exercises 4 | |
Quick test of the routines in module 'cycles' | |
Calculates the number of upcrossings from the turning points. | |
Intensity of trough-crest cycles computed from St |
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
Comments or corrections to the WAFO group