Index Exceeds matrix dimensions error message in my Speech Segmentation code, would you help, please?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2012-10-22
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!