diff options
Diffstat (limited to 'sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m')
| -rw-r--r-- | sourcecodes/bnt-master/SLP/misc/mat_to_bnt.m | 58 |
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 + |
