Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:40:49+00:00 2026-06-12T19:40:49+00:00

How can I set an event in a Simulink Stateflow (statechart) based on some

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:40:51+00:00Added an answer on June 12, 2026 at 7:40 pm

    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:
    enter image description here
    enter image description here

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

    Hope this helps,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can set the event on the calendar on my device by using this
CancelEventArgs provides a Property called Cancel that different event handlers can set to tell
How can you set the event listener for a Spinner when the selected item
How can I set an event handler (such as keydown ) to entire solution,
How can I set a breakpoint to a native library load event in Android?
In XAML you can do <TabItem Selector.Selected=myEvenHandler></TabItem> to set the event handler for when
How can I can set a global variable for the username of the logged-in
In Javascript, how can you set the event handler of a DOM element to
How can I set an onchange event to a tag? I want to transfer
I'm trying to see if I can set a cookie during the Application_Error() event

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.