Disable some or all the optimization for simulink simulation

58 次查看(过去 30 天)
Hi,
I'd like to know if there is option to disable some or all the simulation optimization in Simulink? I sometimes run my simulation in real-time and I modify Constant block while looking at scopes to troubleshoot. Here are the optimization that I do not want and that causes me problem :
  • If I create a logic that originates from a Constant block, I can't have a scope constantly updating. The workaround I found was to set Constant block sampling time to -1 but unfortunately, I can't make Simulink do it by default each time I add a Constant in my model and it's very easy to forget.
  • Some Constant block are modifyable when simulation is running, some are not and I found out it was caused by optimization :
>> set_param(gcb,'Value','0.5')
Cannot change parameter 'Value' of 'Digital_Cmd_Treatment2/p_HW_CMD_DIS1' while simulation is running.
The block was made virtual as it was optimized for simulation.
  • When I run a simulation in Accelerator, almost all my signals yellow label shows "optimized" instead of the signal value.
Is there solution to disable some optimization?
Thank you.

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-1-19
I would suggest using blocks from Simulink Dashboard, e.g. Slider
  2 个评论
Alexandre
Alexandre 2023-1-19
I also found a couple of tricks by try and error such as use "Log selected signal" option on the wire connected to the Constant block.
But from what I understand, Simulink priority is simulation optimization and we can't go back once it's implemented in new releases?
That's not a bad thing but disabling these optimizations would be a good option to add in Simulink Configuration Parameters menu if it's not already done.
Fangjun Jiang
Fangjun Jiang 2023-1-19
编辑:Fangjun Jiang 2023-1-19
The optimization you are looking for is under "Simulation Target", "Block reduction".
When you run simulation in accelerator mode, it generates code first. The optimization is under "code generation", "optimization".
But fundermentally, changing the sample time of a Constant block, or making a signal "test point" is not the right approach. Making the Constant variable "tunable" is the right way. That is basically what the Slider block does.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Manual Performance Optimization 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by