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

32 visualizaciones (últimos 30 días)
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.

Respuestas (2)

Nirmal Gunaseelan
Nirmal Gunaseelan el 14 de Feb. de 2012
Editada: John Kelly el 2 de Mzo. de 2015
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 comentarios
Jette
Jette el 14 de Feb. de 2012
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 el 14 de Feb. de 2012
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.

Iniciar sesión para comentar.


C.J. Harris
C.J. Harris el 14 de Feb. de 2012
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.

Categorías

Más información sobre Model Preparation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by