My model reference block in Simulink does not accept signals of more than one component. Why?
21 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
HINA FATHIMA
il 1 Ott 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
il 11 Mar 2019
Modificato: Bhavin Shiyani
il 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,
Risposte (1)
db1024
il 13 Mag 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 Commenti
Asier Tena
il 17 Set 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
il 3 Set 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:
- Double click on your input.
- Click on the 'signal attributes' tab.
- Change the data type to 'double'.
- 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.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!