You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MATLAB中降采样为何要对滤波器系数进行缩放?

Why h = p*h/sum(h) in MATLAB's resample FIR Filter Design?

Great question! Let's break down the purpose of that final scaling step and the theory behind it.

First, let's recap the context: this code is part of designing the anti-aliasing/interpolation FIR filter for resampling (adjusting the sample rate by a ratio p/q). The firls function designs a linear-phase FIR filter with a target passband gain of 1, and we apply a Kaiser window to control stopband attenuation. But why scale the filter by p/sum(h)?

Core Goal: Preserve DC Component Amplitude

The key reason for this scaling is to ensure the DC (constant) component of the input signal stays identical in the resampled output. MATLAB's resample function guarantees that if you input a constant signal (e.g., x(n) = A), the resampled output will also be A—matching the original amplitude—whether you're upsampling or downsampling.

How the Scaling Works

Let's break it down step by step:

  1. When you design the filter with firls and apply the Kaiser window, the actual DC gain of the filter (sum of its coefficients, sum(h)) won't be exactly 1. Windowing and minor design approximations introduce small deviations from the target passband gain.
  2. The term p/sum(h) normalizes the filter so that its new DC gain becomes p. Here's why p is the right choice for different resampling scenarios:
    • Upsampling case (p > q): First, we insert p-1 zeros between each input sample. This spreads the signal's energy across more samples, so the filter needs a DC gain of p to "fill in" the zeros and restore the original amplitude. After downsampling by q, the final DC component matches the input perfectly.
    • Downsampling case (p < q): We first filter the input to prevent aliasing, then downsample by q. The scaling by p ensures that after downsampling, the DC component's amplitude stays the same as the input. For example, if you're downsampling by 2 (p=1, q=2), scaling by 1/sum(h) sets the filter's DC gain to 1—so the filtered DC signal remains A, and downsampling it keeps that amplitude intact.

Quick Mathematical Check

Suppose we have an input DC signal x(n) = A. For upsampling by p=2 (q=1):

  • The upsampled signal is A, 0, A, 0, ...
  • Filtering with h_new (sum = 2) gives a steady-state output where each sample is A*sum(h_new)/2 = A*2/2 = A—matching the original input's amplitude.

For downsampling by q=2 (p=1):

  • Filtering the constant input A with h_new (sum =1) gives A*1 at every sample. Downsampling picks every 2nd sample, which is still A—preserving the original amplitude.

This scaling step ensures signal integrity by keeping the most basic component of the signal (DC) consistent through the resampling process.

内容的提问来源于stack exchange,提问作者Danijel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:21:55