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

3 次查看(过去 30 天)

采纳的回答

Abhishek GS
Abhishek GS 2015-4-6
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Model Editing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by