How do I change drop - down value of a block in Simulink model for my simulation input object?

2 次查看(过去 30 天)
How do I change drop - down value of a block in a simulink model for my simulation input object? I can't use set_param as it is not supported for deployment.
I want to be able to produce a stand-alone from it.
  2 个评论
Muhammad
Muhammad 2022-10-28
It can be any block containing drop - down options. I want to switch between those options for simulation input object. See I am trying to package simulink model inside app designer app (deployable) and want to give user options to change drop - down values in my model through app.
For my case, I would like to change options of SI or Diesel engine in engine block. Another instance lies in changing drive cycles in relevant drop - down present in drive cycles source block. And probably many more!
If it helps to be more specific, for discussion, we can take a simple example of mass spring damper model shipped with simulink compiler. Command is:
openExample('simulinkcompiler/DeployingASimulationAppUsingSimulinkCompilerExample')
Now lets say we want to add option in app for user to change drop - down value ( for element - wise or matrix multiplication) in the gain block (named 'Mass') of model. How should we do it?

请先登录,再进行评论。

采纳的回答

Fangjun Jiang
Fangjun Jiang 2022-10-28
For changes like this, if you do it manually, meaning changing from 'Element-wise(K.*u)' to 'Matrix(K*u)', the Simulink model is changed. In other words, if you want to do it programingly, you have to use set_param('Block','Multiplication','Matrix(K*u)'). This is not something that can be done by setting up simulation input object.
  2 个评论
Muhammad
Muhammad 2022-10-29
编辑:Muhammad 2022-10-29
Dear MathWorks, This is a very strong limitation (at least, in my experience) in simulink compiler and work should be done to remove it. Regards!
Fangjun Jiang
Fangjun Jiang 2022-10-30
A workaround could be developed using the variant subsystems. Use a workspace variable to control the variants, one uses the 'Element-wise(K.*u)' Gain block, the other uses the 'Matrix(K*u)' Gain block.

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by