How to troubleshhot Code generation error messages ('Dimension 2 is fixed on the left-hand side')?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have been struggeling with a tricky error message that I get during code generation.
I have a Simulink model that contains a block of type 'MATLAB Function' with MATLAB code inside it.
When I generate code for this model I get this error message:
??? Dimension 2 is fixed on the left-hand side but varies on the right ([1 x 1] ~= [1 x :?]).
I have read the documentation and googled it and understand what can cause this error. The problem is that the coder does not point at the location in the code where the problem is. The error is raised much later in the code in the caller of the function where the problem is.
Finding the lines of code that caused the problem took at lot of time since it was in another file than the one pointed to by the error message.
I found that if I generated the code using MATLAB Coder (keeping Simulink out of the loop) with a configuration where variable sizing was disabled (cfg.EnableVariableSizing = 0;) I would get an error message pointing to the correct location. The error message was:
??? Operands must be constants.
The code causing the problem looked something like this:
if myStruct.myVar < 0,
x = 1:par.myVarMax;
else
x = mytruct.myVar;
end
None of my test scenarios actually had a value for 'myStruct.myVar' that was below 0 so the dimentions were always identical on both sides of the calculation that happened at the line were the original error message pointed to.
So my questions are:
- Are there any tricks I could use when troubleshooting Coder errors? Is there any logging going on, any settings I can change to make it more detailed, etc.
- Is it possible to set the 'EnableVariableSizing' option from Simulink?
I am using MATLAB R2014b.
2 comentarios
Denis Gurchenkov
el 25 de Ag. de 2015
You can change the EnableVariableSizing options in the block properties. When you are editing the source code of your MATLAB Function Block, click the "Edit Data" button on the tool strip, and then uncheck "Support variable-sized arrays". That will have same effect as EnableVariableSizing = 0 in codegen.
Respuestas (1)
Rohit Jain
el 26 de Ag. de 2015
To Enable Variable size data using command line, you may find below link useful:
Thanks Rohit
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!