简体   繁体   English

无法从 Simulink 引用 Matlab 单元格数据

[英]Matlab cell data can't be referenced from Simulink

From Matlab, I am calling a python function that returns a list, and I want to load those values into an array that I can pass out to Simulink to work with.在 Matlab 中,我正在调用一个返回列表的 python 函数,我想将这些值加载到一个数组中,我可以将其传递给 Simulink 进行处理。 I can type code into the CommandWindow and get the results I expect:我可以在 CommandWindow 中输入代码并获得我期望的结果:

>> myList = cell(py.myPyModule.myPyFunction());
>> disp(myList);
    [1]    [2]    [3]

>> disp(myList{1});
   1

However, if I put that same code into a Matlab function and call that function from Simulink, that last line gives me an error:但是,如果我将相同的代码放入 Matlab 函数并从 Simulink 调用该函数,最后一行会给我一个错误:

Cell contents reference from a non-cell array object.来自非元胞数组对象的元胞内容引用。

Is there some difference in the two cases?这两种情况有什么不同吗? I can't figure out any way to actually get the data out in the case where I call a Matlab function from Simulink.在我从 Simulink 调用 Matlab 函数的情况下,我无法想出任何方法来实际获取数据。

As I understand it, Simulink doesn't support cell arrays .据我了解, Simulink 不支持 cell arrays Your function should convert your data to a numeric array to be used in Simulink.您的函数应该将您的数据转换为要在 Simulink 中使用的数值数组。 You can use the cell2mat function for this.您可以为此使用cell2mat函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM