-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculus.df
28 lines (20 loc) · 965 Bytes
/
Calculus.df
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
class Calculus
function Derivative(channel)
private derivatives
for (Private.Counter = 1, Counter < NumRows(channel), Counter++)
private currentTime = GetTime(channel[Counter])
private previousTime = GetTime(channel[Counter - 1])
derivatives[Counter - 1] = (channel[Counter] - channel[Counter - 1]) / (currentTime - previousTime)
derivatives[Counter - 1].Time = (currentTime + previousTime) / 2 // Set derivative time to midpoint of sampled data.
endfor
return derivatives
endfunction
function RiemannTrapezoidal(channel)
private integral = 0
for (Private.Counter = 1, Counter < NumRows(channel), Counter++)
integral += (channel[Counter] + channel[Counter - 1]) * Abs(GetTime(channel[Counter]) - GetTime(channel[Counter - 1])) / 2
endfor
return integral
endfunction
endclass
global Calculus = new(Calculus)