Vik*_*ash 2 matlab signal-processing convolution
指数函数与正弦函数卷积的理论结果如下所示。
这两个图看起来很相似,但它们并不相同,请参见比例尺。matlab 良率是理论结果的十倍。为什么?
matlab 代码在这里。
clc;
clear all;
close all;
t = 0:0.1:50;
x1 = exp(-t);
x2 = sin(t);
x = conv(x1,x2);
x_theory = 0.5.*(exp(-t) + sin(t) - cos(t));
figure(1)
subplot(313), plot(t, x(1:length(t))); subplot(311), plot(t, x1(1:length(t))); subplot(312), plot(t, x2(1:length(t)))
figure(2)
subplot(313), plot(t, x_theory); subplot(311), plot(t, x1(1:length(t))); subplot(312), plot(t, x2(1:length(t)))
Run Code Online (Sandbox Code Playgroud)
conv做离散时间卷积,它不做数学积分函数。从数字上讲,这基本上意味着将两个信号的结果相乘和相加多次,每个点一次,其中一个信号有一个小的偏移。
如果您考虑这一点,您就会意识到信号的采样会产生影响。即,如果每 0.1 个值或 0.001 个值有一个点,则乘以的点数不同,因此结果的值不同(不是形状)。
因此,每次进行数值卷积时,总是需要乘以采样率,以“规范化”操作。
只需更改您的代码即可
sampling_rate= 0.1;
t = 0:sampling_rate:50;
x = conv(x1,x2)*sampling_rate;
Run Code Online (Sandbox Code Playgroud)