【问题标题】:Could not determine the size of this expression无法确定此表达式的大小
【发布时间】:2010-05-11 07:17:04
【问题描述】:

最近开始使用MATLAB Simulink,问题是我无法实现AMDF函数,因为simulink编译器无法确定长度。

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

函数“嵌入式 MATLAB Function2”(#38.728.741),第 33 行,第 32 列: "1:flength-k+1"

在解析 Embedded MATLAB 函数“Embedded MATLAB”时出错 函数2'(#38)

嵌入式 MATLAB 接口错误:解析嵌入式 MATLAB 函数“Embedded MATLAB Function2”(#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>


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

亲切的问候

索伦

【问题讨论】:

  • 您能否将您的代码缩进 4 个空格,以便于阅读,好吗?如果您这样做,StackOverflow 将保留您的缩进和语法突出显示您的代码。
  • 或者如果你不喜欢点击首页>四个空格>向下箭头组合一遍又一遍
  • @Doresoom:嗯,我不知道它会那样做。我想这就是我总是在 Vim 中编辑我的帖子所得到的...... :)
  • 这里有类似的问题,如果有帮助的话:stackoverflow.com/questions/1259001/…

标签: matlab simulink


【解决方案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);

【讨论】:

    猜你喜欢
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多