Cell contents reference from a non-cell array object.
Show older comments
function bnet = mk_chmm(N, Q, Y, discrete_obs, coupled, CPD)
if nargin < 2, Q = 2; end
if nargin < 3, Y = 1; end
if nargin < 4, discrete_obs = 0; end
if nargin < 5, coupled = 1; end
if nargin < 6, rnd = 1; else rnd = 0; end
ss = N*2;
hnodes = 1:N;
onodes = (1:N)+N;
intra = zeros(ss);
for i=1:N
intra(hnodes(i), onodes(i))=1;
end
inter = zeros(ss);
if coupled
for i=1:N
inter(i, max(i-1,1):min(i+1,N))=1;
end
else
inter(1:N, 1:N) = eye(N);
end
ns = [Q*ones(1,N) Y*ones(1,N)];
eclass1 = [hnodes onodes];
eclass2 = [hnodes+ss onodes];
if discrete_obs
dnodes = 1:ss;
else
dnodes = hnodes;
end
bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ...
'observed', onodes);
if rnd
for i=hnodes(:)'
bnet.CPD{i} = tabular_CPD(bnet, i);
end
for i=onodes(:)'
if discrete_obs
bnet.CPD{i} = tabular_CPD(bnet, i);
else
bnet.CPD{i} = gaussian_CPD(bnet, i);
end
end
for i=hnodes(:)'+ss
bnet.CPD{i} = tabular_CPD(bnet, i);
end
else
for i=hnodes(:)'
bnet.CPD{i} = tabular_CPD(bnet, i, CPD{i}.CPT);
end
for i=onodes(:)'
if discrete_obs
bnet.CPD{i} = tabular_CPD(bnet, i, CPD{i}.CPT);
else
bnet.CPD{i} = gaussian_CPD(bnet, i, CPD{i}.mean, CPD{i}.cov);
end
end
for i=hnodes(:)'+ss
bnet.CPD{i} = tabular_CPD(bnet, i, CPD{i}.CPT);
end
end
5 Comments
yihao wu
on 14 Apr 2018
Edited: Walter Roberson
on 14 Apr 2018
Walter Roberson
on 14 Apr 2018
This seems to have something to do with Dynamic Bayesian Networks http://www.cs.ubc.ca/~murphyk/Software/BNT/usage_dbn.html but I am not sure which software package you are using.
yihao wu
on 14 Apr 2018
Stephen23
on 14 Apr 2018
What class is bnet.CPD ?
Walter Roberson
on 14 Apr 2018
bnet itself might not be a struct or object. For example bnet might be empty.
Answers (0)
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!