0
votes

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. I can type code into the CommandWindow and get the results I expect:

>> 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:

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.

1
Try cell2mat to turn it into a numeric array.Cris Luengo
Seems the MATLAB Function block can't really use python: stackoverflow.com/q/49354940/2732801Daniel
@Cris, could you post that as an answer so I can mark it as accepted? That was exactly what I needed.David Steadman
@Daniel, the post you reference indicate that the problem was fixed with 2018a. Still, point taken, and I would think carefully before adding python to simulink in a production environment.David Steadman

1 Answers

0
votes

As I understand it, 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 function for this.