-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuspicious_processing_class.cs
78 lines (77 loc) · 2.07 KB
/
Suspicious_processing_class.cs
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
public class Signal_processing
{
public static double[] Zero_average_corr(double [] w, int index)
{
double[] angle,Av;
angle = new double[index];
Av = new double[index];
angle[0] = 0;
for (int i = 1; i < index; i++) angle[i] = Simple_Integration(angle[i-1],w[i],0.01);
for (int i = 0; i < index; i++) Av[i] = Average500(angle,i);
for (int i = 0; i < index; i++) angle[i] = angle[i] - Av[i];
return angle;
}
private static double Simple_Integration(double A, double B, double dt)
{
return A+B*dt;
}
private static double Average50(double[] A, int index)
{
double Summ = 0;
if (index < 25)
{
for (int i = 0; i < index + 25; i++)
{
Summ += A[i];
}
return Summ / (index + 26);
}
if (index >= 25 && A.Length - index > 25)
{
for (int i = index - 25; i < index + 25; i++)
{
Summ += A[i];
}
return Summ / (index + 50);
}
if (A.Length - index < 25)
{
for (int i = index - 25; i < A.Length; i++)
{
Summ += A[i];
}
return Summ / (A.Length - index + 26);
}
return 1;
}
private static double Average500(double[] A, int index)
{
double Summ = 0;
if (index < 250)
{
for (int i = 0; i < index + 199; i++)
{
Summ += A[i];
}
return Summ / (index + 198);
}
if (index>=250 && A.Length-index > 250)
{
for (int i = index - 250; i < index + 250; i++)
{
Summ += A[i];
}
return Summ / 500;
}
if (A.Length - index < 251)
{
for (int i = index - 250; i < A.Length; i++)
{
Summ += A[i];
}
return Summ / (A.Length - index + 249);
}
return 1;
}
}