Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
Jimbob
Posts:
3
Registered:
11/27/12
|
|
'index out of bounds' error
Posted:
Nov 27, 2012 8:28 AM
|
|
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; clc;
%% 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
f=[0:x:35]
%% 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);
end
%% Play file
p = audioplayer (wnoise,Fs); play (p);
|
|
|
|