matlab程序中第二个for循环不执行,直接跳到了if k<n那一句,要怎么解决?很着急,求帮忙!!
cd('D:\buyiguniang\');files=dir('*.wav');n=length(files);A=[];pit=[];fork=1:n;file=['...
cd('D:\buyiguniang\');
files=dir('*.wav');
n=length(files);
A=[];
pit=[];
for k=1:n;
file=['D:\buyiguniang\' files(k).name];
res(k).file=file;
[x,fs,bits]=wavread(file);
y=enframe(x,1024,256);%分帧
framenumber=y/1024;%计算帧数
for k1=1:framenumber;
index1=240*256;
frameSize=1024;
index2=index1+frameSize-1;
frame=y(index1:index2);
plotOpt=1;
amdfVec=frame2amdf(frame, plotOpt);
A=amdfVec;
[row,column]=size(A);
m=column;
for j=2:m;
if A(j)<=A(j-1) & A(j+1)>=A(j);%求谷值
[x1,x2]=find(A==A(j));%求出A(j)的坐标
pit(k)=fs/x2;%求基频
break;
else
j=j+1;
end
end
end
if k<n;
k=k+1;
else
break;
end
end
disp(pit); 展开
files=dir('*.wav');
n=length(files);
A=[];
pit=[];
for k=1:n;
file=['D:\buyiguniang\' files(k).name];
res(k).file=file;
[x,fs,bits]=wavread(file);
y=enframe(x,1024,256);%分帧
framenumber=y/1024;%计算帧数
for k1=1:framenumber;
index1=240*256;
frameSize=1024;
index2=index1+frameSize-1;
frame=y(index1:index2);
plotOpt=1;
amdfVec=frame2amdf(frame, plotOpt);
A=amdfVec;
[row,column]=size(A);
m=column;
for j=2:m;
if A(j)<=A(j-1) & A(j+1)>=A(j);%求谷值
[x1,x2]=find(A==A(j));%求出A(j)的坐标
pit(k)=fs/x2;%求基频
break;
else
j=j+1;
end
end
end
if k<n;
k=k+1;
else
break;
end
end
disp(pit); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询