about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m')
-rw-r--r--sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m b/sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m
new file mode 100644
index 00000000..008cabc8
--- /dev/null
+++ b/sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m
@@ -0,0 +1,58 @@
+function [res] = mat_to_bnt(mat,misv)
+% MAT_TO_BNT Convert a matrix to a cell array
+% D = mat_to_bnt(data,misv)
+%
+% Input : 
+%   data(i,m) is the node i in the case m,
+%   misv is the way you choose to encode missing data
+%               in the original matrix (-9999 by default)
+%
+% Output :
+%  D = cell array containing data(i,m) is the data is OK 
+%                or [] is the data is missing
+%
+%
+% V1.2 : 18 feb 2003 (Ph. Leray - philippe.leray@univ-nantes.fr)
+%
+% >> m=rand(2,4)
+%
+%   m =
+%
+%    0.9525    0.4693    0.3907    0.1496
+%    0.9274    0.3157    0.1346    0.9383
+%
+%  >> m(2,2)=-9
+%
+%   m =
+%
+%    0.9525    0.4693    0.3907    0.1496
+%    0.9274   -9.0000    0.1346    0.9383
+%
+%  >> mat_to_bnt(m,-9)
+%
+%   ans = 
+%
+%    [0.9525]    [0.4693]    [0.3907]    [0.1496]
+%    [0.9274]          []    [0.1346]    [0.9383]
+%
+
+if nargin <1
+    error('Requires at least 1 argument.')
+end
+
+if nargin == 1
+	misv=-9999;
+    end;
+
+taille=size(mat);
+long=taille(1);
+larg=taille(2);
+for i=1:long
+  for j=1:larg
+    res{i,j}=mat(i,j);
+    if(mat(i,j)==misv)
+      res{i,j}=[];
+    end
+  end
+end
+