-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtime_calc_data_processing.m
52 lines (47 loc) · 1.29 KB
/
time_calc_data_processing.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
%# read the whole file to a temporary cell array
filename = 'tdc25nsPulseRe_rslt_txt.txt';
fileid = fopen(filename,'rt');
C = textscan(fileid,'%s');
fclose(fileid);
%celldisp(C)
len = cellfun('length',C);
eightBitNums = zeros((len/2), 1);
twentyBitNums = zeros((len/2), 1);
timeArray = zeros((len/2), 1);
lineArray = zeros((len/2), 1);
index8 = 1;
index20 = 1;
for x = 1 : 7000
timeArray(x, 1) = 7001 - x;
lineArray(x, 1) = 25000;
end
for x = 1 : len
k = strfind(C{1}{x}, 'X');
j = strfind(C{1}{x}, 'U');
%if (mod(x, 2) ~= 0)
if (isempty(k) && isempty(j))
%convert eight bit number to decimal
decNum = bin2dec(C{1}{x});
eightBitNums(index8, 1) = decNum/100;
else
eightBitNums(index8, 1) = 25000;
end;
index8 = index8 + 1;
%else
% if (isempty(k) && isempty(j))
% %convert twenty bit number to decimal
% decNum = bin2dec(C{1}{x});
% twentyBitNums(index20, 1) = decNum;
% else
% twentyBitNums(index20, 1) = 0;
% end;
% index20 = index20 + 1;
%end
end
%plot(eightBitNums, twentyBitNums);
figure;
plot(timeArray, eightBitNums);
hold;
plot(timeArray, lineArray, '+');
% p = polyfit(eightBitNums, twentyBitNums, 1);
% slope = p(1);