How to correctly set instance parameters of model reference?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
0 Commenti
Risposte (1)
Fangjun Jiang
il 21 Ott 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.
Vedere anche
Categorie
Scopri di più su Programmatic Model Editing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!