Index Exceeds matrix dimensions error message in my Speech Segmentation code, would you help, please?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I am trying to segment a signal into its non-zero blocks. Below is the algorithm that I wrote to find the number of non-zero elements in each non-zero block of the signal. the vector Num is supposed to output these numbers. I get the error message: ??? Index exceeds matrix dimensions.
Error in ==> SegmentSignal at 56 if Numcount(j-1,1)==Numtimes
Please Help!
Thank you.
flags =(NormEnergySigX>0.05);
if flags(1)==0
k=0;
Num=[];
Numtimes=0;
Numcount=[];
for j=1:length(flags)
if (flags(Numtimes+1)==0)
Numtimes=0;
end
if flags(j)==0
Numtimes=Numtimes+1;
Numcount(j,1)=(flags(j)==0)*Numtimes;
end
if flags(j)==1
if Numcount(j-1,1)==Numtimes
k=k+1;
Num((Numcount(j-1,1)==Numtimes),k)=Numtimes;
if flags(Numtimes+1)==1
times=0;
if flags(j)==1
Numtimes=Numtimes+1;
Numcount(j,1)=(flags(j)==1)*Numtimes;
if Numcount(j-1,1)==Numtimes
Num((Numcount(j-1,1)==Numtimes),k)=Numtimes; % Num is supposed to contain the number of non-zero elements
% in each consecutive chunks of non-zero elements in flags.
end
end
end
end
end
end
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 22 de Oct. de 2012
You do not create Numcount(j,1) unless flags(j) is 0, or unless flags(j) is 1 and a series of additional conditions all apply. If you were to encounter two locations in a row where the combination of those situations did not apply, then when you went to test Numcount(j-1,1) then that would not have been created yet so you would get the index out of range method.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!