无法确定此表达式的大小

时间:2010-05-11 07:17:05

标签: matlab simulink

我心不在焉地开始使用MATLAB Simulink,我的问题是我无法实现AMDF功能,因为simulink编译器无法确定长度。

Simulink错误:
| --------------------------------------------- ------------------------------------------
无法确定此表达式的大小。

功能'嵌入式MATLAB功能2'(#38.728.741),第33行,第32列: “1:flength-K + 1”

解析嵌入式MATLAB函数'嵌入式MATLAB时出错 功能2'(#38)

嵌入式MATLAB接口错误:解析嵌入式MATLAB函数“嵌入式MATLAB函数2”(#38)时发生错误。
| ------------------------------------------------- --------------------------------------


我的代码:
| ------------------------------------------------- --------------------------------------

function [voiced,minAMDF] = bnrDisAMDF(frame,fs,lvlThr,fspan)<br>
<br>
persistent sLength<br>
persistent fLength<br>
persistent amdf<br>

% Length of the frame<br>
flength = length(frame);<br>

% Pitch period is between 2.5 ms and 19.5 ms for LPC-10 algorithm<br>
% This because this algorithm assumes the frequencyspan is 50 and 400 Hz
pH = ceil((1/min(fspan))*fs);<br>
if(pH > flength)<br>
    pH = flength;<br>
end;<br>
<br>
pL = ceil((1/max(fspan))*fs);<br>
if(pL <= 0 || pL >= flength)<br>
    pL = 0;<br>
end;<br>
<br>
sLength = pH - pL;<br>
<br>
% Normalize the frame<br>
frame = frame/max(max(abs(frame)));<br>
<br>
% Allocating memory for the calculation of the amdf<br>
%amdf = zeros(1,sLength); %%%%%%%%<br>
amdf = 0;<br>
<br>
% Calculating the AMDF with unbiased normalizing<br>
for k = (pL+1):pH<br>
    amdf(k-pL) = sum(abs(frame(1:flength-k+1) - frame(k:flength)))/(flength-k+1);<br>
end;<br>
<br>
% Output of the AMDF<br>
if(min(amdf) < lvlThr)<br>
    voiced = 1;<br>
else<br>
    voiced = 0;<br>
end;<br>
<br>
% Output of the minimum of the amdf<br>
minAMDF = min(amdf);<br>


| ------------------------------------------ ----------------------------------------------
帮助

亲切的问候

索伦

1 个答案:

答案 0 :(得分:1)

waveFile='sunday.wav';
[y, fs, nbits]=wavread(waveFile);
index1=9000;
frameSize=512;
index2=index1+frameSize-1;
frame=y(index1:index2);
maxShift=length(frame);
plotOpt=1;
method=2;
frame2amdf(frame, maxShift, method, plotOpt);