occurance of a error with debugging the code

hello...when I debug this code,I get a error. Can anyone solve it?
%function G729code(speech)
clc;
clear all;
yout=wavread('doormono.wav');
speech=yout';
tic
L=floor(length(speech)/64);
codestream=[];
QuanJuValue(speech);
present_speech=zeros(1,64);
new_speech=zeros(1,64);
total_speech=zeros(1,192);
old_wsp=zeros(1,128);
old_exc=zeros(1,128);
inmapa=[1, 3, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38];
inmapb=[0, 1, 2, 4, 5, 6, 7, 9, 10, 11, 12, 14, 15, 16, 17, 19, 20, 21, 22, 24, 25, 26, 27, 29, 30,31, 32, 34, 35, 36, 37, 39];
%/*----------------------------------------------------------------------*
% * Initialize pointers to speech vector. *
% * *
% * *
% * |--------------------|-------------|-------------|------------| *
% * previous speech sf1 sf2 L_NEXT *
% * *
% * <---------------- Total speech vector (L_TOTAL) -----------> *
% * <---------------- LPC analysis window (L_WINDOW) -----------> *
% * | <-- present frame (L_FRAME) --> *
% * old_speech | <-- new speech (L_FRAME) --> *
% * p_window | | *
% * speech | *
% * new_speech *
% *-----------------------------------------------------------------------*/
for i=1:L
new_speech=round(speech(64*(i-1)+1:64*i)*2^11);
new_speech=round(Pre_Process(new_speech));
total_speech=[total_speech(65:end),new_speech];
present_speech=total_speech(136:200);
%round(total_speech*2^15)
%frame=i-1
[L0code,L1code,L2code,L3code]=LpAnalysis11(total_speech);
[Top,wsp,exc]=Pitch_Open_Loop(total_speech,old_wsp);
%Top
% /* Range for closed loop pitch search in 1st subframe */
tmin=Top-3;
if tmin<10
tmin=10;
end
tmax=tmin+4;
if tmax>143
tmax=143;
tmin=tmax-4;
end
%/*------------------------------------------------------------------------*
%* Loop for every subframe in the analysis frame *
%*------------------------------------------------------------------------*
%* To find the pitch and innovation parameters. The subframe size is *
%* L_SUBFR and the loop is repeated 2 times. *
%* - find the weighted LPC coefficients *
%* - find the LPC residual signal res[] *
%* - compute the target signal for pitch search *
%* - compute impulse response of weighted synthesis filter (h1[]) *
%* - find the closed-loop pitch parameters *
%* - encode the pitch delay *
%* - find target vector for codebook search *
%* - codebook search *
%* - VQ of pitch and codebook gains *
%* - update states of weighting filter *
%*------------------------------------------------------------------------*/
for subframe=1:2
if subframe==1
[Xn2,Gp,Vn,Yn,tmin,tmax,T0,h,Xn,P1,P0]=ClosedLoopPitchSearch(Top,'one',exc,old_exc,tmin,tmax);
% /*-----------------------------------------------------*
% * - Innovative codebook search. *
% *-----------------------------------------------------*/
[position,s,jx,S1,C1,zn,cod]=ACELP_Code_A(Xn2,h,T0,'one');
% /*-----------------------------------------------------*
% * - Quantization of gains. *
% *-----------------------------------------------------*/
[ga,gb,gp,gc]=Qua_gain(Xn,Yn,zn,cod);
%ga
%pause
GA1=dec_bin(inmapa(ga),3);%GA1=bin2dec(GA1(:))';
GB1=dec_bin(inmapb(gb),4);%GB1=bin2dec(GB1(:))';
% /*------------------------------------------------------*
% * - Find the total excitation *
% * - update filters memories for finding the target *
% * vector in the next subframe *
% *------------------------------------------------------*/
exc(1:40)=Memory_update(gp,gc,Vn,cod,Xn,Yn,zn);
else%µÚ¶þ×ÓÖ¡
%round(exc')
[Xn2,Gp,Vn,Yn,tmin,tmax,T0,h,Xn,P2]=ClosedLoopPitchSearch(Top,'two',exc,old_exc,tmin,tmax);
% /*-----------------------------------------------------*
% * - Innovative codebook search. *
% *-----------------------------------------------------*/
[position,s,jx,S2,C2,zn,cod]=ACELP_Code_A(Xn2,h,T0,'two');
% /*-----------------------------------------------------*
% * - Quantization of gains. *
% *-----------------------------------------------------*/
[ga,gb,gp,gc]=Qua_gain(Xn,Yn,zn,cod);
GA2=dec_bin(inmapa(ga),3);%GA2=bin2dec(GA2(:))';
GB2=dec_bin(inmapb(gb),4);%GB2=bin2dec(GB2(:))';
% /*------------------------------------------------------*
% * - Find the total excitation *
% * - update filters memories for finding the target *
% * vector in the next subframe *
% *------------------------------------------------------*/
exc(41:end)=Memory_update(gp,gc,Vn,cod,Xn,Yn,zn);
end
%exc...
end
% /*--------------------------------------------------*
%* Update signal for next frame. *
%* -> shift to the left by L_FRAME: *
%* speech[], wsp[] and exc[] *
%*--------------------------------------------------*/
old_wsp=[old_wsp(64:end),wsp];
old_exc=[old_exc(64:end),exc];
%codestream=[codestream;L0code,L1code,L2code,L3code,P1,P0,C1,S1,GA1,GB1,P2,C2,S2,GA2,GB2];
codestream=[codestream,27425,64,L0code,L1code,L2code,L3code,P1,P0,C1,S1,GA1,GB1,P2,C2,S2,GA2,GB2];
codestream2=codestream;
end
for i=1:length(codestream)
if codestream(i)==0
codestream(i)=127;
elseif codestream(i)==1
codestream(i)=129;
end
end
fid=fopen('coding.bit','w');
count=fwrite(fid,codestream,'int16');
fclose(fid);
toc
Error:??? Index exceeds matrix dimensions.

Answers (1)

The error message would have indicated which line of code the problem was occurring on. It would help us a lot to know where the error is being encountered.

This question is closed.

Tags

Asked:

on 29 Apr 2011

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!