当前位置:网站首页>Adaptive filter
Adaptive filter
2022-07-05 07:59:00 【feiyingzaishi】
1、LMS Filter Module simulation , Output will diverge , Mainly mu The value selection is inappropriate , Just choose a smaller value
2、 You can put online m File by matlab coder The tool is directly converted to C file ( Can't be used directly , Can be compared with reference )
3、 Revised the online C Code for reference
#include "LMS.h"
/* xn-------- Input signal sequence ( Column vector )
* itr------- The number of iterations , Scalar , The default is xn The length of ,M<itr<sizeof(xn)
* en-------- Error sequence (itr*1) Column vector
* dn-------- Desired response sequence ( Column vector )
* M--------- The order of the filter ( Scalar )
* mu-------- Convergence factor ( step ) Scalar
* W--------- Filter weight matrix , The size is M*itr
* yn-------- Actual output sequence ( Column vector )*/
/*LMS Concrete algorithm */
float * LMS_Filter(int itr, const float *xn, const float *dn, double mu, int length)
{
static int i = 0;
static int k = 0;
static float y = 0.0;
static float en[F_COUNT];
static float W[M][F_COUNT];
static float x[M];
static float yn[F_COUNT];
/* Create a en All zero matrix ,en(k) It means the first one k The error between the expected output and the actual input in the second iteration */
for (i=0; i<itr; i++)
{
en[i] = 0;
}
/* Create a W All zero matrix , Each line represents a weighting parameter , Each column represents an iteration */
for (i=0; i<M; i++)
for (k=0; k<itr; k++)
W[i][k] = 0;
/* Create a x All zero matrix */
for (i=0; i<M; i++)
x[i] = 0;
/* Iterative calculation */
for (k=M; k<=itr; k++)
{
/* filter M Input of two taps : from xn The first k-1 Take out the values in reverse order M Put the values of samples into x
* y Output for filter :W Of the K-2 Column and x Sum of products of */
for (i=0; i<M; i++)
{
x[i] = xn[k-i-1];
y += W[i][k-2] * x[i];
}
en[k-1] = dn[k-1] - y; // The first k The error of each iteration
/* Iterative formula for filter weight calculation */
for (i=0; i<M; i++)
{
W[i][k-1] = W[i][k-2] + 2*mu*en[k-1]*x[i];
}
y = 0.0;
}
/* Create a yn Full infinite matrix , Dimension and xn equally */
for (i=0; i<itr; i++)
{
yn[i] = 0.0;
}
/* When finding the optimal output sequence of the filter */
for (k=M; k<=length; k++)
{
for (i=0; i<M; i++)
{
x[i] = xn[k-i-1];
y += W[i][k-2]*x[i];
}
yn[k-1] = y;
y = 0.0;
}
return yn;
}
边栏推荐
- Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
- assert_ Usage of param function
- Application of ultra pure water particle counter in electronic semiconductors
- 万字详解八大排序 必读(代码+动图演示)
- Altium designer 19.1.18 - Import frame
- Global and Chinese markets for recycled boilers 2022-2028: Research Report on technology, participants, trends, market size and share
- Detailed explanation of pragma usage
- Detailed explanation of C language pointer
- The printer encountered an abnormal configuration problem 0x8007007e (win10)
- 生产中影响滑环质量的因素
猜你喜欢
The research found that the cross-border e-commerce customer service system has these five functions!
Measurement fitting based on Halcon learning [i] fuse Hdev routine
研究发现,跨境电商客服系统都有这五点功能!
MySQL - storage engine
Connection mode - bridge and net
万字详解八大排序 必读(代码+动图演示)
生产中影响滑环质量的因素
A complete set of indicators for the 10000 class clean room of electronic semiconductors
High end electronic chips help upgrade traditional oil particle monitoring
Summary -st2.0 Hall angle estimation
随机推荐
Some tips for using source insight (solve the problem of selecting all)
Screen record of the opening ceremony of the Beijing winter olympics 2
Network communication process
How to excavate and research ideas from the paper
Consul安装
LED display equipment records of the opening ceremony of the Beijing Winter Olympics
Acwing-宠物小精灵之收服-(多维01背包+正序倒序+两种形式dp求答案)
Application of ultra pure water particle counter in electronic semiconductors
STM32 knowledge points
Altium Designer 19.1.18 - 导入板框
.NET服务治理之限流中间件-FireflySoft.RateLimit
Global and Chinese market of core pallets 2022-2028: Research Report on technology, participants, trends, market size and share
研究发现,跨境电商客服系统都有这五点功能!
UEFI development learning 6 - creation of protocol
C language # and #
Record the torch encountered by win10 cuda. is_ False problem in available()
Some errors in configuring the environment
Cadence simulation encountered "input.scs": can not open input file change path problem
Summary of STM32 serial port sending and receiving data methods
PMSM dead time compensation