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

21 次查看(过去 30 天)
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 个评论
HINA FATHIMA
HINA FATHIMA 2018-10-1
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 2019-3-11
编辑:Bhavin Shiyani 2019-3-11
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,

请先登录,再进行评论。

回答(1 个)

db1024
db1024 2019-5-13
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 个评论
Asier Tena
Asier Tena 2020-9-17
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
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.

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by