MATLAB“索引越界”错误

时间:2015-10-17 04:28:19

标签: matlab matrix indexing

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

enter image description here

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

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]);

1 个答案:

答案 0 :(得分:0)

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

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

Fst

或(可能)

Fst/(Fs/2)

在MATLAB中执行乘法需要Fst*(Fs/2) 符号。简单地使用圆括号*是不够的,因为它们有另一个目的,Matrix Indexing

相关问题