0
votes

I'm trying to use ml function in Stateflow. because of misunderstanding of my mistake I try example from help: http://www.mathworks.com/help/stateflow/ug/calling-built-in-matlab-functions-and-accessing-workspace-data.html "Which ml Should I Use?" part.

enter image description here

And I get error:

Subscript indices must be of a builtin numeric class. This index has class 'char'.

Transition '[i<5]{...,i,i);}' "'A%d = rand(%d)'"

Debugger thinks that ml is a variable and try to add it into Model Explorer. It can't understand it correctly!

I read help with attention and only place that makes me lost in thoughts:

Caution Because MATLAB functions are not available in a target environment, do not use the ml namespace operator and the ml function if you plan to build a code generation target.

That's only my assumption, but maybe I'm using code generator that's why I have mistake? By the way I tried to Google about code generator, but can't get clearly opinion what is really it... My assumption again is: simulink build-in MATLAB function uses code generator so and Chart in Stateflow. Maybe I need to use some mex files or smth else to avoid using it?

1

1 Answers

0
votes

Two hours of trying and I got this: code generation - it's, let's say, MATLAB language. For using ml we need to set options of Chart to `C language'. Like here: enter image description here

In left bottom corner we can see the Chart type: now it's C. Also you can see this in options.

So select C and ml starts to work.