LSM 自适应信号处理代码
生活随笔
收集整理的這篇文章主要介紹了
LSM 自适应信号处理代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
function [yhat, c, e] = lms(x, y, mu, M, c_0) % function [yhat, c, e] = lms(x, y, mu, M, c_0) % FIR Adaptive Filter using LMS Algorithm, % reference to "Statistical and Adaptive Signal Processing" % by Dimitris G. Manolakis, Vinay K. Ingle, and Stephen M. Kogon. McGraw-Hill Higher Education. % x = input sequence % y = desired sequence % mu = step-size % M = filter order % c_0 = initialization of coefficient vector % yhat = filtered sequence % c = FIR filter coefficient vector % e = error signal % P = squared error if nargin ~= 5 error('The input parameters error!') return end if M <= 0 error('The input filter order must be a postive integer!') return end if sum(size(x)>1)>1 || sum(size(y)>1)>1 || sum(size(c_0)>1)>1 error('Input data dimension error!') return end if length(c_0) ~= M error('initial filter order mismatch!') return end x = squeeze(x); y = squeeze(y); Nx = length(x); x = reshape(x,Nx,1); Ny = length(y); y = reshape(y,Ny,1); c_0 = reshape(c_0,M,1); if Ny > Nx y = y(1:Nx); elseif Ny < Nx y = [y;zeros(Nx-Ny,1)]; end yhat = zeros(Nx,1); c = zeros(M,Nx); P = zeros(Nx,1); e = zeros(Nx,1); xm = zeros(M,1); c(:,1) = c_0; for n = 1:Nx if n < M xm(1:n) = flipud(x(1:n)); else xm = flipud(x(n+1-M:n)); end yhat(n) = xm'*c(:,n); e(n) = y(n)-yhat(n); % P(n) = (abs(e(n)))^2; c(:,n+1) = c(:,n)+2*mu*xm*e(n); end return;轉載于:https://my.oschina.net/innovation/blog/909418
總結
以上是生活随笔為你收集整理的LSM 自适应信号处理代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android性能优化——使用 APK
- 下一篇: 快大三了,该确定专业方向了