Matlab error in vowel extraction code, would you please help?
이전 댓글 표시
Please I need some explanation for why my matlab code is behaving so badly. I absolutely do not see any mistakes in my code, but still matlab outputs this old *"??? Index exceeds matrix dimensions". *I am extremely frustrated. PLEASE HELP. I am really frustrated. I am almost mad. I have been working on this code for so long, and I absolutely think that the problem is with matlab, not my code, really. Below is my code. It is a function that takes as input a sound file.
PLEASE HELP.
THANKS.
function U=Extract_U_in_July(filename)
s=wavread(filename);
s=s./sum(abs(s));
L=length(s);
n=ceil(L/60);
k=L/n;
for i=1:floor(k)
p=1;
for aa=(i-1)*n+1:L-(abs(k-i-1))*n
m(p)=s(aa);
if aa==i*n
Norm(i)=sum(abs(m))/length(m);
end
p=p+1;
end
end
p=1;
for oo=round(k)*n+1:L
m(p)=s(oo);
if oo==L
Norm(i+1)=sum(abs(m))/length(m);
end
p=p+1;
end
Norm=Norm./max(Norm);
ZerosOnes=Norm>Norm(1);
Lenz=length(ZerosOnes);
kk=1;
ii=1;
store=[];
while ii<=Lenz
for l=ii:Lenz
if ZerosOnes(l)==1;
store(kk)=l;
break;
end
end
kk=kk+1;
for ii=l:Lenz
if ZerosOnes(ii)==0
store(kk)=ii-1;
break;
end
end
kk=kk+1;
ii=ii+1;
end
store=store(store~=0)
Ls=length(store);
for jj=1:floor(Ls/2)
if store(jj*2)-store(jj*2-1)==0
store([store(1,:)==store(1,jj*2)])=[];
store([store(1,:)==store(1,jj*2-1)])=[];
end
end
j=1;
for x=1:length(store)/2
count(j)=store(x*2)-store(x*2-1)+1;
j=j+1;
end
IntervalLength=max(count);
for x=1:length(store)/2
if store(x*2)-store(x*2-1)+1==IntervalLength
starting=store(x*2-1);
ending=store(x*2);
end
end
Interval=Norm(starting:ending);
Upeak=findpeaks(Interval,'NPEAKS',1);
plot(Interval)
end
Error in ==> Extract_U_in_July at 60 if store(jj*2)-store(jj*2-1)==0
채택된 답변
추가 답변 (1개)
the cyclist
2013년 2월 3일
편집: the cyclist
2013년 2월 3일
Probably the best way to debug this sort of problem is the following. Before running your code, type the command
>> dbstop if error
Then run your code. This will cause your code to halt execution when it reaches the error. You will be taken to the editor, in debug mode, where the error occurred. Then you can see exactly what is causing the error. Presumably some index into an array is getting larger than you expect.
After you are done, you can remove that by typing
>> dbclear if error
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!