Why "Model arguments can not be used in non-tunable expressions"? in Referenced Simulink Models?

27 次查看(过去 30 天)
I have a Simulink model which also includes SimMechanics-blocks. I would like to change it into a referenced model using "Model arguments" to pass parameters which need to be tuned. (My final goal is to get a protected model with tunable parameters.)
If I run the model (or try to convert it to create a protected model), I get a number of errors like
"Model arguments can not be used in non-tunable expressions. The expression 'mfzg' in parameter field 'Mass' of [.../Body] can not be tuned but it refers to variables (mfzg (model argument))"
The variable mfzg exists in the MATLAB base workspace and in the model workspace and is listed in the Model arguments.
Does anyone know why I get that error? Are there SimMechanics Blocks which do not allow to use tunable variables?
I use R2010b on Windows.

回答(2 个)

Nirmal Gunaseelan
Nirmal Gunaseelan 2012-2-14
编辑:John Kelly 2015-3-2
Model arguments in a referenced model are specifically designed to allow instances of referenced model to be tuned. It appears that your model uses some of these arguments in non-tunable situations and is the reason for that error. These non-tunable parameters have to be defined as global non-tunable parameters to be used in the referenced model. More info can be found at this page on parameterizing.
  2 个评论
Jette
Jette 2012-2-14
I tried the following:
- I configured mfzg (and 2 other parameters with the same error) within the Simulink Model as "Global (tunable) Parameter" with StorageClass "SimulinkGlobal(Auto)"
- I converted the global tunable variables with tunablevars2parameterobjects and afterwards set manually
mfzg.RTWInfo.StorageClass = 'auto'
- I removed these global tunable variables from the list of model arguments of my model
Now, the original error message has vanished but I get
"Body has invalid parameter 'Mass'. 'Mass' must evaluate to a real scalar. Check and reconfigure 'Mass'."
mfzg.Value is a numeric scalar of type double.
Any idea what happened now and what I should do instead?
Nirmal Gunaseelan
Nirmal Gunaseelan 2012-2-14
It seems to me that the model referencing issue is now solved, but some SimMechanics specific error is being thrown. I'll let someone more familiar with SimMechanics answer this. If Body/Mass are some entities that you do not create, you should also contact Tech Support at MathWorks.

请先登录,再进行评论。


C.J. Harris
C.J. Harris 2012-2-14
It would appear as if you are indexing the parameter 'mfgz' based on model parameters. Indexing of this form is not allowed if you want to generate code with tunable parameters, due to the unknown size of the indexed variable. You will need to generate a new variable (i.e. a subset of 'mfgz') if you want a tunable parameter.

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by