Why does my referenced model with the Embedded MATLAB block not work with frame-based signals?

Technical Source
2 min readSep 17, 2021

I built a model which contains frame-based signals and an Embedded MATLAB block, which just runs fine. When I put some parts of my model in a subsystem it also works fine. However when I use model referencing instead of a subsystem, my model produces an error when trying to run:

Cannot propagate frame-based signal from output port 1 of 'mymodel/Constant' to input port 1 of 'mymodel/Model' because this input port expects a sample-based signal. Consider inserting an Unbuffer in the signal path.

The model is exactly the same, but now only some part has been moved to an external referenced file.

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

This is expected behavior. At compile time Real-Time Workshop needs to know the signal properties in order to be able to compile the code properly.

It is not possible to have dynamically sized inputs or outputs for referenced models. When a referenced model is compiled without any knowledge of the model in which it will be used later on, the size and sampling mode for all signals needs to be set explicitly as it cannot be inherited from the referencing model. In the case that the signal size is not set explicitly, it will use a default of a sample based 1x1 signal. So the model will compile succesfully, however its sizes and sampling mode will not match that of the referencing model and therefore lead to an error at runtime.

There are three ways of resolving this problem:

1) Make sure that you set the sizes and sampling modes of all inports and outports correctly in the referenced model so that they are known at compile time. The drawback of this method is that you cannot use a single referenced model for handling signals of different sizes and a change in signal size of the top-level model requires a change in the referenced model. It will, however, allow you to have the normal benefits of a referenced subsystem like speed of execution and incremental code generation.

In order to set the correct sizes for inports, please follow the following steps:

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.