代码拉取完成,页面将自动刷新
同步操作将从 13799673123/myIPC 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UltrasonicTDPlatform
{
class MyAlgorithm
{
public static void CurrentFilter(double[] current, double[] voltage, int len, double k)
{
// 计算电压差分,用来补偿电流脉冲干扰
double[] voltage_dif = new double[len];
for (int i = 1; i < len; i++)
{
voltage_dif[i] = voltage[i] - voltage[i - 1];
current[i] = current[i] - k * voltage_dif[i];
}
// 中值滤波
for (int i = 1; i < len-1; i++)
{
double[] temp = new double[3];
temp[0] = current[i - 1];
temp[1] = current[i];
temp[2] = current[i + 1];
Array.Sort(temp);
current[i] = temp[1];
}
}
}
class FFT
{
int n, m;
// Lookup tables. Only need to recompute when size of FFT changes.
double[] cos;
double[] sin;
public FFT(int n)
{
this.n = n;
this.m = (int)(Math.Log(n) / Math.Log(2));
// Make sure n is a power of 2
if (n != (1 << m))
Console.Out.WriteLine("FFT length must be power of 2");
// precompute tables
cos = new double[n / 2];
sin = new double[n / 2];
for (int i = 0; i < n / 2; i++)
{
cos[i] = Math.Cos(-2 * Math.PI * i / n);
sin[i] = Math.Sin(-2 * Math.PI * i / n);
}
}
///x为实部y为虚部///
public void fft(double[] x, double[] y)
{
int i, j, k, n1, n2, a;
double c, s, t1, t2;
// Bit-reverse
j = 0;
n2 = n / 2;
for (i = 1; i < n - 1; i++)
{
n1 = n2;
while (j >= n1)
{
j = j - n1;
n1 = n1 / 2;
}
j = j + n1;
if (i < j)
{
t1 = x[i];
x[i] = x[j];
x[j] = t1;
t1 = y[i];
y[i] = y[j];
y[j] = t1;
}
}
// FFT
n1 = 0;
n2 = 1;
for (i = 0; i < m; i++)
{
n1 = n2;
n2 = n2 + n2;
a = 0;
for (j = 0; j < n1; j++)
{
c = cos[a];
s = sin[a];
a += 1 << (m - i - 1);
for (k = j; k < n; k = k + n2)
{
t1 = c * x[k + n1] - s * y[k + n1];
t2 = s * x[k + n1] + c * y[k + n1];
x[k + n1] = x[k] - t1;
y[k + n1] = y[k] - t2;
x[k] = x[k] + t1;
y[k] = y[k] + t2;
}
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。