I understand that you want to pass array as input to the function in “Stateflow” diagram as transition condition to next state. To simulate given diagram in your question, I combined three different signals generated by “Signal Generator” block in Simulink using a “Bus Selector” and passed it to the “Stateflow” block as inputs.
To access a particular signal in combined signals, we must mention its index in the array instead of dot operator, since a MATLAB function accepts scalar or array values. The state also needs a condition back to initial state when the signal at that time instant does not meet the tolerance. This allows us to check only a single value of signal at a particular time instant and not entire signal.
Refer to the below diagrams for results achieved using the user-defined tolerance function i.e. “checkInRange” function as given in the question:
- Simulink Model consisting of dummy signals, showing input and output of “Stateflow” block:
- Stateflow diagram to determine tolerance for combined signal:
- Stateflow diagram to determine tolerance for a particular signal, where “User_CMDs(2)”, denotes 2nd signal of input and it is closed inside “[]” to translate it into array:
For more details, kindly refer to the following MathWorks documentation:
- Stateflow: https://www.mathworks.com/help/stateflow/getting-started.html
- Bus Selector: https://www.mathworks.com/help/simulink/slref/busselector.html
To access the documentation for the MATLAB release you are using, please execute the following command in the MATLAB command window:
web(fullfile(docroot, 'stateflow/getting-started.html'))
web(fullfile(docroot, 'simulink/slref/busselector.html'))
Let me know in case you expected a different answer and try to provide your model so that I have correct measurements and block parameters, that you intend to work with.