How to modify step size using my custom Simulink Block

3 次查看(过去 30 天)
Hi,
I have a Simulink block that sets PWM frequency. The things is that the PWM frequency must be the invert of the Simulink step size. I would like to adjust the step size of my Simulink project automatically everytime I modify the PWM frequency. The PWM frequency is set in the mask of my Simulink Block. How should I proceed?
Regards

回答(1 个)

Jesús Zambrano
Jesús Zambrano 2020-3-27
From what I understand, you would like to change the step size of the Solver during time. Step size, as well as other parameters such as sample time are nontunable parameter of the model. The new value will not be used in the current simulation. You need to restart the simulation if you would like to use the new value.
  1 个评论
Benjamin Couillard
Benjamin Couillard 2020-3-30
I want to insure consistency between PWM frequency and sampling time as the relation between the 2 must be "locked". For example a PWM frequency of 1 kHz means the the discrete step size must be 1 ms or 500 µs. I found a way to do it in the Init Function of my custom Simulink block. Perhaps not the best solution, but it works well so far.

请先登录,再进行评论。

类别

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

产品

Community Treasure Hunt

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

Start Hunting!

Translated by