【问题标题】:MATLAB "Index out of bounds" ErrorMATLAB“索引超出范围”错误
【发布时间】:2015-10-17 04:28:19
【问题描述】:

我有一个制作 FIR 滤波器系数的项目,但是在最小阶低通滤波器的过程中出现错误

我不知道这意味着什么以及我需要修复哪个部分:

function [ output_args ] = FIR_FilterCoeff()
N   = 100;        % FIR filter order
Fp  = 20e3;       % 20 kHz passband-edge frequency
Fp  = 20e3;       % 20 kHz passband-edge frequency
Fs  = 96e3;       % 96 kHz sampling frequency
Rp  = 0.00057565; % Corresponds to 0.01 dB peak-to-peak ripple
Rst = 1e-4;       % Corresponds to 80 dB stopband attenuation

NUM = firceqrip (N,Fp/(Fs/2),[Rp Rst],'passedge');

N2= 200; % change filter order to 200

NUM200 = firceqrip(N2,Fp/(Fs/2),[Rp Rst],'passedge');

Fst = 23e3; % transition width = Fst-Fp
NUM_MIN = firgr('minorder',[0,Fp/(Fs/2),Fst(Fs/2),1],[ 1 1 0 0 ],[Rp Rst]);

【问题讨论】:

  • 您不应将错误消息作为图片粘贴到您的问题中。您应该将他们的文本直接复制并粘贴到问题中。请参阅 How to Askminimal reproducible example 了解有关创建好问题的提示。

标签: matlab matrix indexing


【解决方案1】:

您的错误在于最后一行的Fst(Fs/2)Fst 是一个长度为 1 的向量。它有 1 个值 23e3。圆括号 (),在 MATLAB 中直接在变量之后用于 indexing variables

当您键入 Fst(Fs/2) 时,您正试图访问 Fst 中的 48000 元素,但它不存在,因此 MATLAB 会引发错误。我想你可能是这个意思

Fst/(Fs/2)

或(可能)

Fst*(Fs/2)

在 MATLAB 中执行乘法运算需要 * 符号。仅使用圆括号 () 是不够的,因为它们还有另一个用途 Matrix Indexing

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-29
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-02
    相关资源
    最近更新 更多