blob: 008cabc883ddae93beb08c4e783212abca36cb21 (
plain)
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
|
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
|