필터 지우기
필터 지우기

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

조회 수: 23 (최근 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
Marco Delgado Gosálvez 2021년 9월 3일
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에서 Model References에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by