-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddnew.m
More file actions
102 lines (97 loc) · 2.84 KB
/
addnew.m
File metadata and controls
102 lines (97 loc) · 2.84 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function addnew(c,filename1,filepath1,hObject, eventdata, handles)
% c = 1 means open
% c = 2 means import
global rawdata wd whd
nf = int32(str2double(get(handles.text1,'string')));
if (nf == 0)
wd = {};
rawdata = struct('author',[],'title',[],'parameter',[],'time',[],'xylabel',[],...
'xdata',[],'ydata',[],'filename',[]);
end %if
if (c == 1)
stat = 'open';
else %(c == 2)
stat = 'import';
end %if
waitfunc(1,stat, handles)
if (iscell(filename1) == 0)
temp = {};
temp{1} = filename1;
filename1 = temp;
end %if
if (iscell(filename1) == 1)
for i=1:length(filename1)
filenamec=[filepath1 filename1{i}];
if (c == 1)
% Add later to control the error here
load(filenamec,'-mat','rdata','sdata','hdata')
end %if
if (c == 2)
[sdata, rdata, hdata] = excelread2(filenamec);
[~, nam, ~] = fileparts(filename1{i});
nam2 = [filepath1, nam, '.mat'];
% Add later to check the existence of the file and ask to
% overwrite
save(nam2,'sdata','rdata','hdata');
end %if
rawdata(nf+1) = sdata;
if (nf == 0)
[wd, ~, ~] = property();
whd = hiddenprop();
% wd = rdata;
% else
%tempdata = data2(2:end,:);
% wd = [wd;rdata(2:end,:)];
end %if
tempdata = cell([(size(rdata,1)-1) size(wd,2)]);
for j=1:size(rdata,2)
[ind, ~] = detect(rdata{1,j});
if (ind ~= 0)
tempdata(:,ind) = rdata(2:end,j);
end %if
end %j
wd = [wd;tempdata];
whd = [whd;hdata(2:end,:)];
nf = nf + 1;
end %i
% nf = nf + length(filename1);
% else
% filenamec=[filepath1 filename1];
% if (c == 1)
% load(filenamec,'-mat','rdata','sdata','hdata')
% end %if
% if (c == 2)
% [sdata, rdata, hdata] = excelread2(filenamec);
% [~, nam, ~] = fileparts(filename1);
% nam2 = [filepath1, nam, '.mat'];
% save(nam2,'sdata','rdata','hdata');
% end %if
% rawdata(nf+1) = sdata;
%
% if (nf == 0)
% [wd, ~, ~] = property();
% whd = hiddenprop();
% % [wd, ~, ~] = property()
% % for
% % wd = rdata;
% % else
% % wd = [wd;rdata(2:end,:)];
% end %if
% tempdata = cell([(size(rdata,1)-1) size(wd,2)]);
% for j=1:size(rdata,2)
% [ind, ~] = detect(rdata{1,j});
% if (ind ~= 0)
% tempdata(:,ind) = rdata(2:end,j);
% end %if
% end %j
% wd = [wd;tempdata];
% whd = [whd;hdata(2:end,:)];
% nf = nf + 1;
end %if
set(handles.text1,'string',num2str(nf))
adddata(handles)
alist = checkdata(wd);
adddata2(alist, hObject, eventdata, handles);
waitfunc(0,'import', handles)
assignin('base', 'whd', whd);
assignin('base', 'wd', wd);