-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathay_create_state_space.m
87 lines (74 loc) · 2.85 KB
/
ay_create_state_space.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function Param = ay_create_state_space(nx,nUk,nIn,nIb,xM,cLink,cLinkUpdate,dLink,dLinkUpdate)
%% Build The State-Space Model
nc = 1;
nd = 1;
%% Dimension of Components
% Size of X vector
Param.nx = nx;
Param.nc = 1;
Param.nd = 1;
%% Input and Their Link Functions
% Input and its link to the continuous model
Param.nIn = nIn; % Bias, I, V, I2C, C2I
if ~isempty(cLink) && ~isempty(cLinkUpdate)
% The cLinkMap - continuous link map
Param.cLinkMap = zeros(nc,size(xM,1));
for i=1:nc
Param.cLinkMap(i,:) = cLink(i,:);
Param.cLinkUpdate(i,:)= cLinkUpdate(i,:);
end
end
% Input and its link to the discrete model
Param.nIb = nIb; % Bias, I, V, I2C, C2I
if ~isempty(dLink) && ~isempty(dLinkUpdate)
% The dLinkMap - discrete link map
Param.dLinkMap = zeros(nd,size(xM,1));
for i=1:nd
Param.dLinkMap(i,:) = dLink(i,:);
Param.dLinkUpdate(i,:)= dLinkUpdate(i,:);
end
end
%% Model Paramaters
% Hidden state model -
Param.Ak = eye(Param.nx,Param.nx);
Param.Bk = ones(Param.nx,nUk)*0.0; % input
Param.Wk = eye(Param.nx,Param.nx)*0.01; % iid noise
Param.X0 = zeros(Param.nx,1); % initial x0 is set to 0
Param.W0 = eye(Param.nx,Param.nx)*100; % initial x0 is set to 0
% Continuous model
Param.Ck = ones(nc,size(xM,1)); % coefficients of the x
Param.Dk = ones(nc,Param.nIn); % input parameters
% we need to drop some input from update
Param.cConstantUpdate= ones(nc,Param.nIn);
if ~isempty(cLink) && ~isempty(cLinkUpdate)
for i=1:nc
ind = find(Param.cLinkMap(i,:));
Param.cConstantUpdate(i,Param.cLinkMap(i,ind))=0;
end
end
Param.Vk = eye(nc,nc)*0.001; % noise
% Disceret model
Param.Ek = ones(nd,size(xM,1)); % coefficients of the x
Param.Fk = ones(nd,Param.nIb); % input parameters
% we need to drop some input from update
if ~isempty(dLink) && ~isempty(dLinkUpdate)
Param.dConstantUpdate= ones(nd,Param.nIb);
for i=1:nd
ind = find(Param.dLinkMap(i,:));
Param.dConstantUpdate(i,Param.dLinkMap(i,ind))=0;
end
end
% xM is the X Mapping
Param.xM = xM;
% two extra paramaters for Gamma (Param.Vk is beging treated as Dispression)
Param.S = 0;
% set censor_time + processing model
Param.censor_time = 1;
Param.censor_mode = 1; % mode 1: sampling, mode 2: full likelihood
% mode 1 is applicable on all data types
% mode 2 is defined on continuous variable
Param.censor_update_mode=1; % how the run the filter rule
% it define how the Kalman Filter is getting updated - two different
% mehtods
Param.UpdateMode=1;
end