code written in MATLAB function should be paused for some instant but simulation should never be paused.

1 次查看(过去 30 天)
generally in my project capacitor voltages diverge. So, i have written a code to converge them to a nominal voltage.
Now i want observe whether my work was proper or not. for that i have three instances.
First: Both code and simulation should run
second: Code has to be disabled but simulation should be running.
Third: code has to be re-enabled and simulation should be running.
now my problem is, Is it possible disable entire code for some time but simulation should be running at the background?
and after some time can we re enable it?
Note: At any instant simulation should be running(i.e., simulation should not be paused or stopped)

回答(1 个)

Pratyush
Pratyush 2024-5-31
Hi Aravind,
To control the execution of specific code segments in MATLAB while a simulation runs continuously, you can use the following strategies:
  1. Use a flag variable with 'if' statements to enable or disable code segments based on the flag's state. This method allows for manual or conditional toggling of code execution while the simulation continues.
  2. Implement a MATLAB GUI or listen for network messages to interactively control the execution of your code. This approach is suitable for scenarios requiring user interaction or network-based toggling.
  3. Utilize MATLAB's timer functions to schedule enabling and disabling of code segments automatically. This is useful for scenarios where code execution needs to be toggled after specific intervals.
Note: ensure your simulation can run independently of the toggled code, consider real-time execution limits of MATLAB, and thoroughly test your setup to avoid unexpected behavior. These strategies allow for the dynamic control of code execution alongside uninterrupted simulation.

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by