线性卷积

==================== 持续更新,敬请指正 =================


1. 线性卷积的基本理论

线性卷积是对线性移不变(LSI)系统的输入输出关系的描述,体现系统的特性。



线性卷积的表达式为


一般情况,现实的系统为因果系统,有k<0时,恒有h(k)=0,则


此时输出y(n)也为因果信号。


若x(n)是一个N点序列,h(n)是一个m点序列,则卷积的结果y(n)将是L=N+M-1点的序列


卷积是一种典型的乘累加运算,非常适合在DSP处理器上实现。


2. 线性卷积的matlab实现

function y=conv(x,h,show_flag)
% 线性卷积的实现 y=x*h
% if show_flag=1 plot x and result in matlab
%
% Author: xiahouzuoxin
%   Date: 2013-11-21

if nargin < 3
  show_flag = 0;
end

N = length(x);
M = length(h);
L = M+N-1;

y = zeros(L,1);

for n=1:N
  for k=1:M
    y(n+k-1) = y(n+k-1) + x(n)*h(k);
  end 
end

if show_flag == 1
  figure,
  max_val = max([max(y),max(x),max(h)]);
  subplot(2,2,1),stem(x);title('x(n)');grid on;axis([0 L 0 max_val])
  subplot(2,2,2),stem(h);title('h(n)');grid on;axis([0 L 0 max_val])
  subplot(2,2,3),stem(y);title('y(n)');grid on;axis([0 L 0 max_val])
end

设x=[1 2 3],h=[1 3 5 6],则调用conv([1 2 3], [1 3 5 6], 1)后,在matlab中绘制出如下图,


在matlab的库函数中已有实现好的卷积算法,使用help conv查阅,

>> help conv
 CONV Convolution and polynomial multiplication.
    C = CONV(A, B) convolves vectors A and B.  The resulting vector is
    length MAX([LENGTH(A)+LENGTH(B)-1,LENGTH(A),LENGTH(B)]). If A and B are
    vectors of polynomial coefficients, convolving them is equivalent to
    multiplying the two polynomials.
 
    C = CONV(A, B, SHAPE) returns a subsection of the convolution with size
    specified by SHAPE:
      'full'  - (default) returns the full convolution,
      'same'  - returns the central part of the convolution
                that is the same size as A.
      'valid' - returns only those parts of the convolution 
                that are computed without the zero-padded edges. 
                LENGTH(C)is MAX(LENGTH(A)-MAX(0,LENGTH(B)-1),0).


3. 线性卷积的C实现

参考本博客内文章: 离散卷积运算的DSP实现


参考文献

【1】胡广书,数字信号处理——理论、算法与实现


  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值