Is it possible to toggle a manual switch via pressing a keyboard button in a running Simulink environment?

3 views (last 30 days)

Accepted Answer

Abhishek GS
Abhishek GS on 6 Apr 2015
Hi TZEEEE,
If you are looking to control the 'Manual Switch' via keyboard, I am afraid it is not possible by pressing a simple keyboard button. The closest you get could get to it is by using a 'Switch' block like below.
Now, while this model is running (Lets say Stop Time = inf), on the command line you will have to enter the following commands:
ctrl = 1 % or ctrl = 0
set_param(gcs,'SimulationCommand','Update')
Once, the Simulink Model is updated the new value for the variable 'ctrl' used in the ControlValue constant block takes its effect.
Note that you could also update the model using keyboard shortcut "Ctrl+D".
Thanks, Abhishek

More Answers (0)

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!