Home > wafo > cycles > dtp2rfm_sid.m

# dtp2rfm_sid

## PURPOSE

Rainflow matrix from discrete turning points with side information.

## SYNOPSIS

[RFM,RFM0,res,RFMsid,RFM0sid,res_sid] = dtp2rfm_sid(x,y,n,ny,def)

## DESCRIPTION

``` DTP2RFM_SID  Rainflow matrix from discrete turning points with side information.

CALL:  [RFM,RFM0,res,RFM0sid,res_sid] = dtp2rfm(x,y,n,r,def)

RFM     = Rainflow Matrix (residual included).    [n,n]
RFM0    = Rainflow matrix (without resudual).     [n,n]
res     = Residual.                               [2*n,1]
RFMsid  = Rainflow Matrix with side information (residual included).
{r,r1}[n,n]
RFMsid  = Rainflow Matrix with side information (without resudual).
{r,r1}[n,n]
res_sid = Residual for side information.          [2*n,1]

x     = Turning points (taking values 1,...,n).    [T,1]
y     = Side information (taking values 1,...,r).  [T,1]
n     = Number of levels.
r     = Number of levels in side information..
def   = Which type of side information
1: Mark min & max, r1=r
2: Mark when counted, r1=1
RFM0  = Rainflow matrix (without resudual).     [n,n]
res   = Residual.                               [2*n,1]

Example: (Two processes as in Example 4.1 in PhD thesis)
P = [0.9 0.1; 0.05 0.95];
param = [-1 1 32]; u = levels(param);
F1 = mktestmat(param,[-0.4 -0.3],0.15,1);
F2 = mktestmat(param,[0.3 0.4],0.15,1);
[x,z] = smctpsim(P,{F1 F1'; F2 F2'},10000); % Two regime states
[RFM,RFM0,res,RFMsid,RFM0sid,res_sid] = dtp2rfm_sid(x,z,32,2,1);
figure(1),cmatplot(u,u,RFMsid,3)
RFM1 = RFMsid{1,1}+RFMsid{1,2}+RFMsid{2,1}+RFMsid{2,2};
figure(2),cmatplot(u,u,{RFM RFM1},3) % Shall be identical

## CROSS-REFERENCE INFORMATION

This function calls:
 dtp2arfm_sid Asymmetric RFM from discrete TP with side information. error Display message and abort function. triu Extract upper triangular part.
This function is called by:

## SOURCE CODE

```001 function [RFM,RFM0,res,RFMsid,RFM0sid,res_sid] = dtp2rfm_sid(x,y,n,ny,def)
002 %DTP2RFM_SID  Rainflow matrix from discrete turning points with side information.
003 %
004 % CALL:  [RFM,RFM0,res,RFM0sid,res_sid] = dtp2rfm(x,y,n,r,def)
005 %
006 % RFM     = Rainflow Matrix (residual included).    [n,n]
007 % RFM0    = Rainflow matrix (without resudual).     [n,n]
008 % res     = Residual.                               [2*n,1]
009 % RFMsid  = Rainflow Matrix with side information (residual included).
010 %                                                   {r,r1}[n,n]
011 % RFMsid  = Rainflow Matrix with side information (without resudual).
012 %                                                   {r,r1}[n,n]
013 % res_sid = Residual for side information.          [2*n,1]
014 %
015 % x     = Turning points (taking values 1,...,n).    [T,1]
016 % y     = Side information (taking values 1,...,r).  [T,1]
017 % n     = Number of levels.
018 % r     = Number of levels in side information..
019 % def   = Which type of side information
020 %          1: Mark min & max, r1=r
021 %          2: Mark when counted, r1=1
022 % RFM0  = Rainflow matrix (without resudual).     [n,n]
023 % res   = Residual.                               [2*n,1]
024 %
025 % Example: (Two processes as in Example 4.1 in PhD thesis)
026 %   P = [0.9 0.1; 0.05 0.95];
027 %   param = [-1 1 32]; u = levels(param);
028 %   F1 = mktestmat(param,[-0.4 -0.3],0.15,1);
029 %   F2 = mktestmat(param,[0.3 0.4],0.15,1);
030 %   [x,z] = smctpsim(P,{F1 F1'; F2 F2'},10000); % Two regime states
031 %   [RFM,RFM0,res,RFMsid,RFM0sid,res_sid] = dtp2rfm_sid(x,z,32,2,1);
032 %   figure(1),cmatplot(u,u,RFMsid,3)
033 %   RFM1 = RFMsid{1,1}+RFMsid{1,2}+RFMsid{2,1}+RFMsid{2,2};
034 %   figure(2),cmatplot(u,u,{RFM RFM1},3) % Shall be identical
035 %
037
038 % References:
039 %
040 %  P. Johannesson (1999):
041 %  Rainflow Analysis of Switching Markov Loads.
042 %  PhD thesis, Mathematical Statistics, Centre for Mathematical Sciences,
043 %  Lund Institute of Technology.
044
045 % Tested  on Matlab  5.3
046 %
047 % History:
048 % Revised by PJ  09-Apr-2001
049 %   updated for WAFO
050 % Created by PJ (Pär Johannesson) 1998
051 % Copyright (c) 1997-1998 by Pär Johannesson
052 % Toolbox: Rainflow Cycles for Switching Processes V.1.1, 22-Jan-1998
053
054
055 ni = nargin;
056 no = nargout;
057 error(nargchk(5,5,ni));
058
059 % Calculate asymmetric RFM and res
060
061 [RFM,RFM0,res,RFMsid,RFM0sid,res_sid] = dtp2arfm_sid(x,y,n,ny,def);
062
063 % Convert to symmetric rainflow
064
065 RFM = triu(RFM+RFM');
066 RFM0 = triu(RFM0+RFM0');
067 if def == 1
068   for iy=1:ny
069     for jy=1:ny
070       RFMsid{iy,jy} = triu(RFMsid{iy,jy}+RFMsid{iy,jy}');
071       RFM0sid{iy,jy} = triu(RFM0sid{iy,jy}+RFM0sid{iy,jy}');
072     end
073   end
074 end
075 if def == 2
076   for iy=1:ny
077     RFMsid{iy,1} = triu(RFMsid{iy,1}+RFMsid{iy,1}');
078     RFM0sid{iy,1} = triu(RFM0sid{iy,1}+RFM0sid{iy,1}');
079   end
080 end
081
082```

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