Home > wafo > cycles > cmat2rmcmat.m

# cmat2rmcmat

## PURPOSE

Converts a cycle matrix from Range-Mean format to min-max format.

## SYNOPSIS

[Frm,paramM,paramR,paramA] = cmat2rmcmat(F,param)

## DESCRIPTION

```  CMAT2RMCMAT  Converts a cycle matrix from Range-Mean format to min-max format.

CALL:  Frm = cmat2rmcmat(F);
[Frm,paramM,paramR,paramA] = cmat2rmcmat(F,param);

Input:
F      = Cycle matrix in min-max format.   [nxn]
param  = [a b n] ; defines discretization of levels.
Output:
Frm    = Cycle matrix in range-mean format.   [nxn]
paramM = [aM bM n] ; defines discretization of mean-values.
paramR = [aR bR n] ; defines discretization of ranges.
paramA = [aA bA n] ; defines discretization of amplitudes.

NB! Due to different discretizations for Frm and F,
the mean values will not be identical.

## CROSS-REFERENCE INFORMATION

This function calls:
 error Display message and abort function.
This function is called by:
 test_cycles Quick test of the routines in module 'cycles'

## SOURCE CODE

```001 function [Frm,paramM,paramR,paramA] = cmat2rmcmat(F,param)
002 % CMAT2RMCMAT  Converts a cycle matrix from Range-Mean format to min-max format.
003 %
004 % CALL:  Frm = cmat2rmcmat(F);
005 %       [Frm,paramM,paramR,paramA] = cmat2rmcmat(F,param);
006 %
007 % Input:
008 %   F      = Cycle matrix in min-max format.   [nxn]
009 %   param  = [a b n] ; defines discretization of levels.
010 % Output:
011 %   Frm    = Cycle matrix in range-mean format.   [nxn]
012 %   paramM = [aM bM n] ; defines discretization of mean-values.
013 %   paramR = [aR bR n] ; defines discretization of ranges.
014 %   paramA = [aA bA n] ; defines discretization of amplitudes.
015 %
016 % NB! Due to different discretizations for Frm and F,
017 %     the mean values will not be identical.
018 %
020
021 % Tested  on Matlab  5.3
022 %
023 % History:
024 % Revised by PJ 18-May-2000
025 %   Updated help text.
026 % Created by PJ (Pär Johannesson) 12-Apr-2000
027
028 % Check input arguments
029
030 ni = nargin;
031 no = nargout;
032 error(nargchk(1,2,ni));
033
034 % Initiate matrices
035 n = length(F);
036 Frm = zeros(n,n);
037
038 % Convert
039
040 for i = 1:n
041   for j = i:n
042     if F(i,j) ~= 0
043       r = j-i+1;
044       m = floor((i+j)/2);
045       Frm(r,m) = F(i,j);
046     end
047   end
048 end
049
050 if ni>1
051   paramM = param;  % Mean values
052   paramR(3) = n;   % Ranges
053   paramR(1) = (paramM(2)-paramM(1))/(n-1)/2;
054   paramR(2) = paramR(1)+(paramM(2)-paramM(1));
055   paramA = [paramR(1:2)/2 paramR(3)];  % Amplitudes
056 end
057```

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