C#实现算术平均 滤波算法 输入List<double>返回List<double>
时间: 2024-06-09 12:01:23 浏览: 163
基于C与arduino的算术平均滤波法设计与实现
以下是 C# 实现算术平均滤波算法的代码,输入 List<double>,返回 List<double>:
```csharp
public static List<double> ArithmeticMeanFilter(List<double> inputList, int windowSize)
{
List<double> outputList = new List<double>();
for (int i = 0; i < inputList.Count; i++)
{
if (i < windowSize - 1)
{
outputList.Add(inputList[i]);
}
else
{
double sum = 0;
for (int j = i - windowSize + 1; j <= i; j++)
{
sum += inputList[j];
}
double mean = sum / windowSize;
outputList.Add(mean);
}
}
return outputList;
}
```
阅读全文