The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: 'index out of bounds' error
Replies: 5   Last Post: Nov 27, 2012 9:56 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 3
Registered: 11/27/12
'index out of bounds' error
Posted: Nov 27, 2012 8:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi. I have a small error that I'm sure is down to my inexperience. Any help with this would be more than grateful!

I'm trying to script a Vocoder, that splits an audio signal into a number of filtered bands before processing them individually. The script below calculates the frequency bands and allocates them to 'Wp' for use in the filter.

The for loop is supposed to allocate the frequency bands from Wp for each channel before processing with another function (not scripted here).

The error from Matlab is as follows:


Attempted to access Wp(2,3); index out of bounds because size(Wp)=[1,6].

Error in voc4channel (line 43)
[b, a] = ellip (n, Rp, Rs, Wp(i,i+1));


And here's the script. Once again, if anybody can point me in the right direction I can move on. I'm currently very frustrated!


clear all;
close all;

%% Load test sound:

fileName = uigetfile('*.wav');
[y, Fs, nbits] = wavread(fileName);

y_voc_out = zeros(size(y)); % initialise the output of the vocoder

%% Number of Channels: 1:24

numchan = input ('How Many Bands (1-24):')

%% Define the frequency bands

x = 35/numchan


%% Calculate Wp

Wp = (165.4*(10.^(0.06*f)-1))/(Fs/2)

%% Other filter settings

n = 5; % order of filter
Rp = 1; % dBripple in the passband
Rs = 70; % dB drop between pass and stop

%% Split into channels

for i=1:numchan % loop to split into channels

[b, a] = ellip (n, Rp, Rs, Wp(i,i+1));
y_channel = filter(b, a, y);


%% Play file

p = audioplayer (wnoise,Fs);
play (p);

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.