-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeDfm.m
58 lines (48 loc) · 1.27 KB
/
makeDfm.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
function makeDfm(dirname,dfmname)
% Make directory feature matrix.
% makeDfm('./','a'), will make ./a.dfm
if nargin==0
dirname='';
end
if nargin==0
dfmname='';
end
fprintf(1,'Make directory feature matrix now...\n');
files=getFilesInDir('*.fv.mat',dirname);
if isempty(files)
fprintf(1,'There is no fv.mat files.\n');
return;
end
% drm=struct([]); % Empty struct with no field.
dataNum=length(files);
obfile=cell(dataNum,1); % Observation filename str-cell.
load(files{1},'fVec','fnames');
varNum=length(fVec);
dfm=zeros(dataNum,varNum);
dfm(1,:)=fVec;
obfile(1)=files(1);
% If dataNum==1, it will be ok.
for i=2:dataNum
load(files{i});
dfm(i,:)=fVec;
obfile(i)=files(i);
end
if isempty(dfmname)
[pathname filename]=fileparts(files{i});
sprintf(filename);
[file pathname]=uiputfile(fullfile(pathname,'res.dfm'),'Save the dfm');
% If user press cancel, file is 0.
if ~file
return;
end
dfmname=fullfile(pathname,file);
save(dfmname,'dfm','obfile','fnames');
else
dfmname=[dfmname '.dfm'];
save(dfmname,'dfm','obfile','fnames');
end
pathname=fileparts(dfmname);
sprintf(pathname);
copyfile(dfmname,[pathname filesep '..']); % copy the filename to parent directory.
fprintf(1,'DFM of %s is generated.\n',dirname);
end