Home > wafo > cycles > cmat2amp.m

cmat2amp

PURPOSE ^

Calculates a histogram of amplitudes from a cycle matrix.

SYNOPSIS ^

amp_hist = cmat2amp(param,F)

DESCRIPTION ^

 CMAT2AMP Calculates a histogram of amplitudes from a cycle matrix.
 
  CALL:  amp_hist = cmat2amp(param,F);
 
    amp_hist = a two column matrix with amplitudes (defined by  param)
               in the first column and frequencies in the second.
    param    = the parameter matrix.
    F        = the  nxn  frequency matrix for the cycle count.
 
  Example:
    x = load('sea.dat');                   % Load data
    [dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
    RFM = dtp2rfm(dtp,32);                 % Calculate rainflow matrix
    amp_hist = cmat2amp([-2 2 32],RFM);    % Get amplitude histigram
    bar(amp_hist(:,1),amp_hist(:,2))       % Plot histogram
 
  See also  cc2cmat

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function amp_hist = cmat2amp(param,F)
002 %CMAT2AMP Calculates a histogram of amplitudes from a cycle matrix.
003 %
004 % CALL:  amp_hist = cmat2amp(param,F);
005 %
006 %   amp_hist = a two column matrix with amplitudes (defined by  param)
007 %              in the first column and frequencies in the second.
008 %   param    = the parameter matrix.
009 %   F        = the  nxn  frequency matrix for the cycle count.
010 %
011 % Example:
012 %   x = load('sea.dat');                   % Load data
013 %   [dtp,u,tp] = dat2dtp([-2 2 32],x,0.2); % Discrete TP & rainflow filter 0.2
014 %   RFM = dtp2rfm(dtp,32);                 % Calculate rainflow matrix
015 %   amp_hist = cmat2amp([-2 2 32],RFM);    % Get amplitude histigram
016 %   bar(amp_hist(:,1),amp_hist(:,2))       % Plot histogram
017 %
018 % See also  cc2cmat 
019 
020 % Tested  on Matlab  5.3
021 %
022 % History:
023 % Created by PJ (Pär Johannesson) 03-Nov-1999
024 
025 % Check input arguments
026 
027 ni = nargin;
028 no = nargout;
029 error(nargchk(2,2,ni));
030 
031 n=param(3); % Number of discrete levels
032 
033 amp_hist=zeros(n,2);
034 
035 
036 % First column: The values of the amplitudes
037 amp_hist(:,1) = levels([0 param(2)-param(1) n])'/2;
038 
039 % Second  column: The number of amplitudes
040 for i=0:n-1
041   amp_hist(i+1,2)=sum(diag(F,i));
042 end
043

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