【问题标题】:Interpreted MATLAB Function block error in simulink在 simulink 中解释了 MATLAB Function 模块错误
【发布时间】:2015-11-09 15:21:55
【问题描述】:

我创建如下的 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 文件中定义了这些 denoise,lfcc,vqext,knnclassify 函数。但我收到如下错误。

我该如何解决这个问题?

【问题讨论】:

    标签: matlab simulink


    【解决方案1】:

    在您的图片中,我们可以看到您的数据正式具有两个维度 [1024x1] !所以我认为,解释型 MATLAB 函数不能使用这种数据类型进行操作。

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

    附:顺便说一句,你为什么使用解释功能?真的有必要吗?

    注意这个块比 Fcn 块慢,因为它调用 每个集成步骤中的 MATLAB 解析器。考虑使用内置 块(例如 Fcn 块或 Math Function 块)。 或者,您可以将函数编写为 MATLAB S-Function 或 MEX 文件 S-Function,然后使用 S-Function 块访问它。

    【讨论】:

    • 谢谢@Mikhail_Sam
    • 我发现的另一个问题是加载 mat 文件。它仅加载到工作空间中。我通过 dataset=load('train.mat'); 解决特征=数据集。特征; type=dataset.type;
    • @ Mikhail_Sam 我想在不使用电脑的情况下在树莓派中运行这个模型。我有多个用于解释 matlab 函数的 .m 文件。你能帮帮我吗?
    • 我真的没有使用树莓派的经验,但我们当然可以尝试——在 matlab 和 simulink 中使用 .mat 文件是一种常见的做法。但我建议您针对您的确切问题提出新问题 - 我和很多人会帮助您!
    • @ Mikhail_Sam 我在解释函数的不同文件中有很多 matlab 函数(去噪,lfcc,vqext)。在这种情况下我可以使用 MATLAB S-Function 吗?
    猜你喜欢
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-31
    相关资源
    最近更新 更多