-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataConversion.m
41 lines (41 loc) · 1.51 KB
/
DataConversion.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
clear
foldername = uigetdir('C:\Users\Public\Documents\','选择要转换的文件夹');
load([foldername '\Data.mat'], 'Discontinuity','Filename')
Filename = replace(string(Filename), '_', '-');
Filename = char(Filename);
Data = dir([foldername '\*.csv']);
Data = rmfield(Data,["date", "isdir", "datenum"]);
for ii = 1:length(Data)
if contains(Data(ii).name, "-PSET")
Data(ii).type = 'PULSE';
Data(ii).Process = 'SET';
elseif contains(Data(ii).name, "-PRESET")
Data(ii).type = 'PULSE';
Data(ii).Process = 'RESET';
elseif contains(Data(ii).name, "-SET")
Data(ii).type = 'SWEEP';
Data(ii).Process = 'SET';
elseif contains(Data(ii).name, "-RESET")
Data(ii).type = 'SWEEP';
Data(ii).Process = 'RESET';
else
Data(ii).type = 'TIME';
Data(ii).Process = 'TIME';
end
Data(ii).date = datetime(Data(ii).name(1:15) , 'InputFormat', 'yyyyMMdd-HHmmss');
cache = load([Data(ii).folder '\' Data(ii).name]);
Data(ii).Time = cache(:,1);
Data(ii).Voltage = cache(:,2);
Data(ii).Current = cache(:,3);
Data(ii).Discontinuity = 1;
Data(ii).Delete = false;
index = find(contains(string(Filename(:,1:15)), Data(ii).name(1:15)));
if ~isempty(index)
Data(ii).Delete = contains(string(Filename(index,:)), 'set');
if ~Data(ii).Delete
Data(ii).Discontinuity = Discontinuity(index);
end
end
end
movefile([foldername '\Data.mat'], [foldername '\old.mat'])
save([foldername '\Data.mat'], 'Data')