-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfreqToTS.m
More file actions
42 lines (34 loc) · 1.33 KB
/
freqToTS.m
File metadata and controls
42 lines (34 loc) · 1.33 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
function freqToTS(opID, theTree,samplingTime)
% disp("Freq")
% disp(opID);
nodeParent = getparent(theTree,opID);
operatorSubTree = theTree.subtree(nodeParent);
%
theNodes = nnodes(operatorSubTree);
s = '';
totalFStr = '';
disp(operatorSubTree.tostring);
% for i=1:theNodes
% disp(i)
% disp(operatorSubTree.get(i));
% end
fStr = operatorSubTree.get(8);
%
f = str2double( fStr );
toleranceString = operatorSubTree.get(7);
toleranceValue = str2double( toleranceString );
if (operatorSubTree.get(1) == '<')
totalF = (1/samplingTime*(f+toleranceValue)) + 1;
totalFStr = string(totalF);
end
if (operatorSubTree.get(1) == '>')
totalF = (1/samplingTime*(f-toleranceValue)) - 1;
totalFStr = string(totalF);
end
s = strcat('T2','(',operatorSubTree.get(5),operatorSubTree.get(4),operatorSubTree.get(6),')','-'...
,'T1','(',operatorSubTree.get(5),operatorSubTree.get(4),operatorSubTree.get(6),')',operatorSubTree.get(1),totalFStr);
fileID = fopen('convertedConstraints.txt','a');
fprintf(fileID,s);
fprintf(fileID,newline);
fclose(fileID);
end