How to generate state flow condition?

543 Views Asked by At

I am trying to create a state machine (state flow). The input is a vector.
The condition for a switch in one direction is:

[vector(vector < 494 | vector > 631)]

and for the other direction:

[vector(vector > 494 & vector < 631)]

But I get an error message in the diagnostic viewer window:

Illegal use of a matrix or vector type where a scalar was expected.

Why? But If I type these conditions in the MATLAB command window there is no error message.

1

There are 1 best solutions below

0
On

Your bracket statements contain logical indexing of vector.

If you type them at the matlab prompt you will get a vector/array containing all the elments fulfilling the condition.

However, for stateflow the brackets indicate a condition for a transition and must evaluate to a single (scalar) true/false. There it makes no sense to arrive at a selection of the elements of vector.

If you are instead interested of making a transition whenever vector is less than 494 or greater than 631 the transition should look like:

[vector < 494 || vector > 631]

And vector has to be a scalar in the stateflow context.