views:

74

answers:

0

Hi, I have resently started to use MATLAB Simulink, and my problem is that i can't implement an AMDF function, because simulink compiler cannot determine the lengths.

Simulink errors:
|---------------------------------------------------------------------------------------
Could not determine the size of this expression.

Function 'Embedded MATLAB Function2' (#38.728.741), line 33, column 32: "1:flength-k+1"

Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function2'(#38)

Embedded MATLAB Interface Error: Errors occurred during parsing of Embedded MATLAB function 'Embedded MATLAB Function2'(#38) .
|---------------------------------------------------------------------------------------


MY CODE:
|---------------------------------------------------------------------------------------
persistent sLength
persistent fLength
persistent amdf

% Length of the frame
flength = length(frame);

% Pitch period is between 2.5 ms and 19.5 ms for LPC-10 algorithm
% This because this algorithm assumes the frequencyspan is 50 and 400 Hz pH = ceil((1/min(fspan))*fs);
if(pH > flength)
pH = flength;
end;

pL = ceil((1/max(fspan))*fs);
if(pL <= 0 || pL >= flength)
pL = 0;
end;

sLength = pH - pL;

% Normalize the frame
frame = frame/max(max(abs(frame)));

% Allocating memory for the calculation of the amdf
%amdf = zeros(1,sLength); %%%%%%%%
amdf = 0;

% Calculating the AMDF with unbiased normalizing
for k = (pL+1):pH
amdf(k-pL) = sum(abs(frame(1:flength-k+1) - frame(k:flength)))/(flength-k+1);
end;

% Output of the AMDF
if(min(amdf) < lvlThr)
voiced = 1;
else
voiced = 0;
end;

% Output of the minimum of the amdf
minAMDF = min(amdf);

|----------------------------------------------------------------------------------------
HELP

Kind regards

Søren

related questions