My model reference block in Simulink does not accept signals of more than one component. Why?

20 vues (au cours des 30 derniers jours)
Hi,
I am pretty new to the Model reference block in Simulink. I tried to start with a toy case where:
The top model has only one constant (scalar) that enters the model reference and reads the output
The referenced model returns the double (gain multiplication, element wise).
It works when I use a scalar as the input but when I use a two component vector I get: -Error in port widths or dimensions. Output port 1 of 'simulink_plant/Constant' is a one dimensional vector with 2 elements. -Error in port widths or dimensions. Input port 1 of 'simulink_plant/Model1' is a one dimensional vector with 1 elements.
I don't understand why this happens. The inport in the referenced model has Inherit: auto as data type. I guess it is something silly but I have spent hours with this. Thanks,
Miguel
  3 commentaires
HINA FATHIMA
HINA FATHIMA le 1 Oct 2018
Hi Any updates on this problem? I am also experiencing passing a vector input to a referenced model. Kindly share the solution if you have any.....
Bhavin Shiyani
Bhavin Shiyani le 11 Mar 2019
Modifié(e) : Bhavin Shiyani le 11 Mar 2019
Hi,
I am also facing the same issue.
One solution is to specify port dimension in signal attribute, but it will work only for specific input dimensions.
If anyone has generalized solution the please share the solution.
Thanks,

Connectez-vous pour commenter.

Réponses (1)

db1024
db1024 le 13 Mai 2019
The reason might be that model reference blocks are context-independent according to Capabilities of Model Components.
I think you need to create a library block to get inherited port dimensions.
  2 commentaires
Asier Tena
Asier Tena le 17 Sep 2020
Hi,
Yeah it seems that signal properties do not propagate across parent model and referenced model boundaries. However, our approach needs both: model references and tuneable input port dimension. Assuming these project limitations, is there any work around?
An easy example is the following. We have a model reference block which has a N size vector as an input. It simply calculates de max value of that array and returns it. That referenced model could be instanced in different parts of the parent model, with different input dimension on each instance.
Marco Delgado Gosálvez
Marco Delgado Gosálvez le 3 Sep 2021
It indeed seems to be that once you make a model reference in Simulink, the context between the current model and the imported model is lost. That means that the input data type property, which is by default set to inherit the data type automatically, will not work.
Instead set the input data property to the data type you are expecting.
In the case you are passing a vector to the referenced model, adapt the input of the referenced model like this:
  1. Double click on your input.
  2. Click on the 'signal attributes' tab.
  3. Change the data type to 'double'.
  4. Write in 'port dimensions' the dimension of your vector. If you are just working with 1-D vectors, just write your number n in there. If you need to specify more dimensions, e.g. 2-D vectors, write [m n], where m is the number of rows, and n is the number of columns. (Reference, last accessed 3-Sep-2021: http://www.ece.northwestern.edu/local-apps/matlabhelp/toolbox/simulink/slref/inport.html)
This should work then.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by