# 一、卷积计算原理

x

(

n

)

x(n)

x(n) 是 LTI 系统的 " 输入序列 " ,

y

(

n

)

y(n)

y(n) 是 " 输出序列 " ,

y

(

n

)

=

m

=

+

x

(

m

)

h

(

n

m

)

=

x

(

n

)

h

(

n

)

y(n) = sum^{+infty}_{m = -infty} x(m) h(n-m) = x(n) * h(n)

y(n)=m=+x(m)h(nm)=x(n)h(n)

" 输出序列 "

" 输入序列 "" 系统单位脉冲响应 "线性卷积 ;

=

+

1

=+1

# 二、卷积计算

x

(

n

)

=

{

1

,

2

}

[

0

,

1

]

x(n) = {1,2}_{[0, 1]}

x(n)={1,2}[0,1]

h

(

n

)

=

{

1

,

2

}

[

0

,

1

]

h(n) = {1,2}_{[0, 1]}

h(n)={1,2}[0,1]

x

(

n

)

h

(

n

)

x(n) * h(n)

x(n)h(n) ;

2

+

2

1

=

3

2 + 2 - 1 = 3

2+21=3

y

(

n

)

=

m

=

+

x

(

m

)

h

(

n

m

)

=

x

(

n

)

h

(

n

)

y(n) = sum^{+infty}_{m = -infty} x(m) h(n-m) = x(n) * h(n)

y(n)=m=+x(m)h(nm)=x(n)h(n)

x

(

n

)

h

(

n

)

=

m

=

+

x

(

m

)

h

(

n

m

)

x(n) * h(n) = sum^{+infty}_{m = -infty} x(m) h(n-m)

x(n)h(n)=m=+x(m)h(nm)

## 1、计算 y(0)

y

(

0

)

y(0)

y(0) :

m

=

+

x

(

m

)

h

(

0

m

)

sum^{+infty}_{m = -infty} x(m) h(0-m)

m=+x(m)h(0m)

m

m

m 取值

[

,

+

]

[-infty, +infty]

[,+]

m

<

0

m < 0

m<0 时 , 有

x

(

m

)

=

0

x(m) = 0

x(m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m) h(n-m) = 0

x(m)h(nm)=0 , 累加没有意义 ;

m

=

0

m = 0

m=0 时 , 有

x

(

0

)

h

(

0

0

)

=

x

(

0

)

h

(

0

)

=

1

×

1

=

1

x(0)h(0 - 0) = x(0)h(0) = 1 times 1 = 1

x(0)h(00)=x(0)h(0)=1×1=1

m

1

m geq 1

m1 时 , 有

h

(

n

m

)

=

h

(

0

m

)

=

0

h(n - m) = h(0 - m) = 0

h(nm)=h(0m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m)h(n - m) = 0

x(m)h(nm)=0 , 累加没有意义 ;

y

(

0

)

=

x

(

0

)

h

(

0

)

=

1

×

1

=

1

y(0) = x(0)h(0)= 1 times 1 = 1

y(0)=x(0)h(0)=1×1=1

## 2、计算 y(1)

y

(

1

)

y(1)

y(1) :

m

=

+

x

(

m

)

h

(

1

m

)

sum^{+infty}_{m = -infty} x(m) h(1-m)

m=+x(m)h(1m)

m

m

m 取值

[

,

+

]

[-infty, +infty]

[,+]

m

<

0

m < 0

m<0 时 , 有

x

(

m

)

=

0

x(m) = 0

x(m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m) h(n-m) = 0

x(m)h(nm)=0 , 累加没有意义 ;

m

=

0

m = 0

m=0 时 , 有

x

(

m

)

h

(

n

m

)

=

x

(

0

)

h

(

1

0

)

=

x

(

0

)

h

(

1

)

=

1

×

2

=

2

x(m) h(n-m) = x(0)h(1 - 0) = x(0)h(1) = 1 times 2 = 2

x(m)h(nm)=x(0)h(10)=x(0)h(1)=1×2=2

m

=

1

m = 1

m=1 时 , 有

x

(

m

)

h

(

n

m

)

=

x

(

1

)

h

(

1

1

)

=

x

(

1

)

h

(

0

)

=

2

×

1

=

2

x(m) h(n-m) = x(1)h(1 - 1) = x(1)h(0) = 2 times 1 = 2

x(m)h(nm)=x(1)h(11)=x(1)h(0)=2×1=2

m

2

m geq 2

m2 时 , 有

h

(

n

m

)

=

h

(

2

m

)

=

0

h(n - m) = h(2 - m) = 0

h(nm)=h(2m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m)h(n - m) = 0

x(m)h(nm)=0 , 累加没有意义 ;

y

(

1

)

=

x

(

0

)

h

(

1

)

+

x

(

1

)

h

(

0

)

=

2

+

2

=

4

y(1) = x(0)h(1)+x(1)h(0) = 2 + 2 = 4

y(1)=x(0)h(1)+x(1)h(0)=2+2=4

## 3、计算 y(2)

y

(

2

)

y(2)

y(2) :

m

=

+

x

(

m

)

h

(

2

m

)

sum^{+infty}_{m = -infty} x(m) h(2-m)

m=+x(m)h(2m)

m

m

m 取值

[

,

+

]

[-infty, +infty]

[,+]

m

<

0

m < 0

m<0 时 , 有

x

(

m

)

=

0

x(m) = 0

x(m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m) h(n-m) = 0

x(m)h(nm)=0 , 累加没有意义 ;

m

=

0

m = 0

m=0 时 , 有

x

(

m

)

h

(

n

m

)

=

x

(

0

)

h

(

2

0

)

=

x

(

0

)

h

(

2

)

=

1

×

0

=

0

x(m) h(n-m) = x(0)h(2 - 0) = x(0)h(2) = 1 times 0 = 0

x(m)h(nm)=x(0)h(20)=x(0)h(2)=1×0=0 ,

h

h

h 仅在

0

,

1

0,1

0,1 索引有值 ,

2

2

2 索引值为 0 ;

m

=

1

m = 1

m=1 时 , 有

x

(

m

)

h

(

n

m

)

=

x

(

1

)

h

(

2

1

)

=

x

(

1

)

h

(

1

)

=

2

×

2

=

4

x(m) h(n-m) = x(1)h(2 - 1) = x(1)h(1) = 2 times 2 = 4

x(m)h(nm)=x(1)h(21)=x(1)h(1)=2×2=4

m

2

m geq 2

m2 时 , 有

h

(

n

m

)

=

h

(

2

m

)

=

0

h(n - m) = h(2 - m) = 0

h(nm)=h(2m)=0 , 则

x

(

m

)

h

(

n

m

)

=

0

x(m)h(n - m) = 0

x(m)h(nm)=0 , 累加没有意义 ,

h

h

h 仅在

0

,

1

0,1

0,1 索引有值 , 小于

0

0

0 的索引值为 0 ;

y

(

1

)

=

x

(

0

)

h

(

1

)

+

x

(

1

)

h

(

0

)

=

0

+

4

=

4

y(1) = x(0)h(1)+x(1)h(0) = 0 + 4 = 4

y(1)=x(0)h(1)+x(1)h(0)=0+4=4

# 三、使用 matlab 计算卷积

matlab 源码 :

x = [1, 2];
h = [1, 2];

y = conv(x, h);


y

(

n

)

=

{

1

,

4

,

4

}

[

0

,

2

]

y(n) = {1,4,4}_{[0,2]}

y(n)={1,4,4}[0,2]

# 四、使用 C 语言实现卷积计算

void convolution(double *input1, double *input2, double *output, int mm, int nn)
{
double *xx = new double[mm + nn - 1];
// do convolution
for (int i = 0; i < mm + nn - 1; i++)
{
xx[i] = 0.0;
for (int j = 0; j < mm; j++)
{
if (i - j >= 0 && i - j < nn)
xx[i] += input1[j] * input2[i - j];
}
}
// set value to the output array
for (int i = 0; i < mm + nn - 1; i++)
output[i] = xx[i];
delete[] xx;
}


THE END