Clear Filters
Clear Filters

bwboundaries() C++ code Generation Error

5 views (last 30 days)
abc def
abc def on 23 Aug 2022
Answered: Yash on 15 Jan 2024
%%I have enabled dynamic memory allocation in Simulation Target > Advanced parameters with default threshold as 0.
B={{nan}}; %%Defining so that it can be set as size variable.
coder.varsize('B',[50 1]);
B={B;bwboundaries(BW,'noholes')} %%Not B{:}=bwboundaries() as multiple inputs are not allowed
Y=B{2}
boundary=Y{2}
=== Simulation (Elapsed: 1:21 min) ===
Error:Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Error:This assignment writes a 'cell' value into a 'double' type in element '{1}{1}'. Code generation does not support changing types through assignment. Check preceding assignments or input type specifications for type mismatches.
Function 'Image Processing System/corner_detection' (#95.612.613), line 21, column 1:
"B"
Launch diagnostic report.
Error:Errors occurred during parsing of MATLAB function 'flightControlSystem/Image Processing System/corner_detection'
Error:Simulink cannot determine sizes and/or types of the outputs for block 'flightControlSystem/Image Processing System/corner_detection' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Error:Simulink cannot determine sizes and/or types of the outputs for block 'flightControlSystem/Image Processing System/corner_detection' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.

Accepted Answer

Yash
Yash on 15 Jan 2024
Hi,
The error message indicates that Simulink is having trouble determining the output sizes for a block within the 'corner_detection' function of your 'flightControlSystem/Image Processing System'. There are two main issues highlighted:
  1. Type Mismatch Error: The error message ''This assignment writes a 'cell' value into a 'double' type in element '{1}{1}''' suggests that there's an attempt to assign a cell array to a variable that was previously defined or assumed to be a double. Code generation in MATLAB doesn't support changing variable types through assignment.
  2. Size Determination Error: Simulink is unable to infer the sizes of the block outputs. This can be due to the dynamic nature of cell arrays, particularly when their sizes are not fixed at compile time.
To resolve type mismatches, ensure variables maintain consistent types throughout; a variable initially set as a double should not be reassigned to a cell array later on. Create distinct variables for different types or use only cell arrays if necessary. When dealing with variable-sized data, like 'coder.varsize('B',[50 1])', provide explicit size information to Simulink, either by defining output sizes in the MATLAB function block or using assert to confirm variable sizes. Code generation demands static typing, so once a variable's type is established, it should not change.
Hope this helps!

More Answers (0)

Categories

Find more on Embedded Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!