convolution.m

来自「AR模型的源程序。」· M 代码 · 共 21 行

M
21
字号
% File: convolution.m
% -------------------
% This file is used to compute the convolution of two sequences.

function [y_output] = convolution(x_input, h_input)
% y_output: convolution output
% h_input:  hir filter
% x_input:  input sequence
L = length(x_input); % length of input sequence
M = length(h_input) - 1; % order of hir filter
y_output = zeros(L + M, 1);
y_output_cast = zeros(L + M + 1, 1);
for n = 2: (L + M + 1)
    y_output_cast(n) = 0;
    for m = max(1, (n - L)): min((n - 1), (M + 1))
        y_output_cast(n) = y_output_cast(n) + h_input(m) * x_input(n - m);
    end
end
for n = 1: (L + M)
    y_output(n) = y_output_cast(n + 1);
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?