How can I set an event in a Simulink Stateflow (statechart) based on some value. What I mean is this. I have a variable called "choice". This "choice" comes in as an input from a simulink block.The value of choice is between 1 and 4. So all I want to do is this:
if choice == 1 then trigger/set eventBlue
if choice == 2 then trigger/set eventRed
if choice == 3 then trigger/set eventWhite
if choice == 4 then trigger/set eventGreen
else trigger/set eventYellow
So how do i do that? what is the command?
I suggest you take a look to the stateflow webinars: http://www.mathworks.com/products/stateflow/ . There are also many examples of stateflow that may help you understanding how to use the library. Check this help webpage: http://www.mathworks.com/help/stateflow/examples/index.html
It is difficult to know exactly what you want to do, but you can draw the arrows that indicate state changes and add a function that checks the value of the variable choice. First you have to configure your statechart to admit 'choice' as input from simulink. Define the states and in the arrow transitions put '[choice == 1]', '[choice == 2]', etc (without the '').
You should obtain a model like this:

The pulse generator is configured to create a sequence of zeros and ones, to activate the transitions.
Hope this helps,