解释 simulink 中的 MATLAB Function 块错误

Interpreted MATLAB Function block error in simulink

我创建如下所示的 simulink 块:

在解释的 MATLAB 函数中我使用了这段代码。

function y1 = fcn(signal)
%% variable declaration
Fm = 100;%length of Frames excursion
framelnc = 100;%length of Frames excursion
Fn = 256;%length of Frames sampling frequency 12.500kHz, frame length 020.5ms
fs = 8000;

x=signal;

%% Preprocessing: Noise Removal
IS= 0.25; % initial silence (noise only)
output=denoise(x,fs,IS);
y = output;

%% Extraction of LFCC Features
feat = lfcc(y,fs);

%% Extract VQ CODE
k=16; % number of centroids required

code1 = vqext(feat, k);
test = mean2(code1);

%% Emotions Recognition 
load ('train.mat')

Class = knnclassify(test , feature, type);

if (Class == 1)
   %% Display identification results
   msg=1;
end

if (Class == 2)
   %% Display identification results
    msg=2;
end

y1 = msg;

我在单独的 matlab 文件中定义了这些 denoiselfccvqextknnclassify 函数。但我得到如下错误。

我该如何解决这个问题?

从你的图片我们可以看出,你的数据形式上是二维的[1024x1]!所以我认为,解释型 MATLAB 函数不能使用这种数据类型。

所以我建议使用帧转换块。

P.S。顺便问一下,你为什么要使用解释函数?真的有必要吗?

Note This block is slower than the Fcn block because it calls the MATLAB parser during each integration step. Consider using built-in blocks (such as the Fcn block or the Math Function block) instead. Alternatively, you can write the function as a MATLAB S-function or MEX-file S-function, then access it using the S-Function block.