-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFixHashValues.m
52 lines (43 loc) · 1.49 KB
/
FixHashValues.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
path = 'o:\';
% EnergyCalcExp.generate_catalog(path);
% S = load([path, 'catalog.mat']);
% lib = S.lib;
% mykeys = lib.keys;
% myvals = lib.values;
for ikey = 1:length(mykeys)
curkey = lib(mykeys{ikey});
efm = curkey.Efield_mag;
newefm = str2double(num2str(efm, 5));
% newefm = num2str(int32(floor(efm)));
% efm = efm - str2double(newefm);
% newefm = [newefm, '.'];
%
% decimal_buffer = [];
% getOut = false;
% for prec = 1:10
% if (~getOut)
% efm = efm * 10;
% digit = num2str(int32(floor(efm)));
% if (strcmp(digit,'0') && (length(decimal_buffer) < 5))
% decimal_buffer = [decimal_buffer, '0'];
% elseif (strcmp(digit,'0') && (length(decimal_buffer) == 5))
% getOut = true;
% else
% newefm = [newefm, decimal_buffer, digit];
% end
% efm = efm - str2double(digit);
% end
% end
curkey.Efield_mag = str2double(newefm);
hash = DataHash(curkey);
if (~strcmp(mykeys{ikey}, hash))
if (exist([path, mykeys{ikey}, '.mat'], 'file'))
movefile([path, mykeys{ikey}, '.mat'],[path, hash, '.mat']);
S = load([path, hash, '.mat']);
S.key = curkey;
S.hash = hash;
save([path, hash, '.mat'], '-struct', 'S');
end
movefile([path, mykeys{ikey}, '-dm.bin'],[path, hash, '-dm.bin']);
end
end