How to correctly set instance parameters of model reference?

8 visualizaciones (últimos 30 días)
Malte Kliemann
Malte Kliemann el 21 de Oct. de 2020
Comentada: Malte Kliemann el 22 de Oct. de 2020
According to Parameterize a Referenced Model Programmatically, you can programatically change instance parameters of a model reference ex_model_arg/Model as follows:
instSpecParams = get_param('ex_model_arg/Model','InstanceParameters');
instSpecParams(1).Value = '.98';
instSpecParams(1).Argument = true;
set_param('ex_model_arg/Model','InstanceParameters',instSpecParams);
However, I run into a multitude of problems doing this. First of all, instSpecParams is an 0×1 empty struct array with fields Name, Value, Path, Argument, and it's not supposed to be. I don't know what could cause this. This means that I have to manually fill out all fields before submitting the struct to set_param. The function of Name, Value and Argument are clear.
However, I cannot find any info on what Path is. Furthermore, if I get the InstanceParameters paramter from my own models (not the examples), then there is not Path field, but rather a FullPath field. Ignoring this will lead to the following error (both in the examples and my own model):
To set model parameters, use a structure array with fields 'Name', 'Value', 'FullPath', and 'Argument'.
Again, I cannot find anything on what FullPath is.
To summarize: The documentation appears to be outdated or wrong, or I'm under a grave misapprehension. How can I programatically change instance parameters of a model reference?

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 21 de Oct. de 2020
In the referenced model, you need to create workspace variables, set 'ParameterArgumentNames' first as described in the document. Otherwise, when it is referenced in another model, 'InstanceParameters' will return as an empty structure.
The field name is always "Path" for me for example models and my models in R2020a. The "FullPath" referenced in the error message might be misleading. Try above first to be able to get the structure and then see what is the field name for your model.
  2 comentarios
Malte Kliemann
Malte Kliemann el 22 de Oct. de 2020
Thanks! That was my bad, didn't read properly. Apparently, you need to set the ParameterArgumentNames parameter, otherwise you get the incorrect fields in the return value.
Malte Kliemann
Malte Kliemann el 22 de Oct. de 2020
Nevermind, the problem persists when trying to use the python engine to perform this task.

Iniciar sesión para comentar.

Categorías

Más información sobre Automotive Applications en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by