Where to find Variable Size for output of Matlab function in Simulink

31 visualizaciones (últimos 30 días)
I am working with a Simulink code with a Stateflow chart in R2016a. My code communicates with a real time machine (Speedgoat) that sends binary signals to a motor. I keep getting this error message and I'm not sure how to appropriately deal with it.
Error: Data 'y' is inferred as a variable size matrix, while its properties in the Model Explorer specify its size as inherited or fixed. Please check the 'Variable Size' check box and specify the upper bounds in the size field.
When the instructions say to "check the 'Variable Size' check box and specify the upper bounds" I have no idea where in Simulink I should go to do this, so where to find that is my immediate question but I fear this will just cascade into further errors (see Further Information below). More often then not, the dialog box provides a hyperlink that send me to correct line in the code, or block where the error is occuring but nothing was provided in this case.
Further Information:
The data y is an output from a function Write running in Simulink. The inputs write_type and 'stroke' come from the Stateflow chart and crc_table comes from a constant block. Please ignore the red error from the Serial Write HW FIFO block. I am making changes to the code on a separate machine, and building the code on a machine where the speedgoat library is installed.
I am fairly certain that the size of the output y changes at each execution step. It doesn't progressively get larger at infinitum but it switches between different sizes. I'm trying to figure out what the maximum size could be, but when I wasn't using Stateflow to generate these inputs but was using a series of Simulink blocks and Matlab functions in a previous version of my code I never got this error. I'm not asking it in this question, but I have also been getting errors saying "Index expression out of bounds." that goes away after I initialize other variables in functions that are used in Write, and when I click on more info from the error it mentions something about how arrays cannot increase in size using C/C++ compilers. That's why I've included the compiler tag. Lastly, I'm not the only one in my lab using these functions inside Write or Stateflow on this release, but I am the only one getting these errors so that suggests to me they have some settings that are different than I and I'm not sure what they would be.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 17 de Jun. de 2021
double click the MATLAB Function block to open the code editor, Click "Edit Data" button/icon, select the variable on the left column, check "Variable size" on the right.
Please note, this is just the way to mark it "Variable size". There is no guarantee this will resolve your problem.
  1 comentario
Nathaniel H Werner
Nathaniel H Werner el 17 de Jun. de 2021
Thanks, I found that myself. It turns out the problem is significantly more complicated and has something to do with Stateflow. The other colleague who is not having these issues is using a code someone else wrote and whenever I try to even open their code I get several warnings.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Complex Logic en Help Center y File Exchange.

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by