无法从 Simulink 引用 Matlab 单元格数据
Matlab cell data can't be referenced from Simulink
我在 Matlab 中调用一个 python 函数,该函数 returns 一个列表,我想将这些值加载到一个数组中,我可以将该数组传递给 Simulink 进行处理。我可以在 CommandWindow 中键入代码并获得我期望的结果:
>> myList = cell(py.myPyModule.myPyFunction());
>> disp(myList);
[1] [2] [3]
>> disp(myList{1});
1
但是,如果我将相同的代码放入 Matlab 函数并从 Simulink 调用该函数,最后一行会给我一个错误:
Cell contents reference from a non-cell array object.
这两种情况有什么区别吗?在我从 Simulink 调用 Matlab 函数的情况下,我想不出任何方法来实际获取数据。
据我了解,Simulink doesn't support cell arrays. Your function should convert your data to a numeric array to be used in Simulink. You can use the cell2mat
功能。
我在 Matlab 中调用一个 python 函数,该函数 returns 一个列表,我想将这些值加载到一个数组中,我可以将该数组传递给 Simulink 进行处理。我可以在 CommandWindow 中键入代码并获得我期望的结果:
>> myList = cell(py.myPyModule.myPyFunction());
>> disp(myList);
[1] [2] [3]
>> disp(myList{1});
1
但是,如果我将相同的代码放入 Matlab 函数并从 Simulink 调用该函数,最后一行会给我一个错误:
Cell contents reference from a non-cell array object.
这两种情况有什么区别吗?在我从 Simulink 调用 Matlab 函数的情况下,我想不出任何方法来实际获取数据。
据我了解,Simulink doesn't support cell arrays. Your function should convert your data to a numeric array to be used in Simulink. You can use the cell2mat
功能。