Why do I get an error when converting my MATLAB code (which utilizes "bwlabel") to C code using MATLAB Coder?
1 回表示 (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2018 年 9 月 7 日
編集済み: MathWorks Support Team
2019 年 5 月 16 日
I am trying to generate C/C++ code from my MATLAB program, which utilizes "bwlabel".
However, I encounter the following error message:
??? Computed maximum size of output #1 of function 'intermediateLabelRuns' is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [:? x 1].
Please consider enabling dynamic memory allocation to allow unbounded sizes.
Here is an excerpt of my example code:
im_bin = zeros(dim_X,dim_Y);
coder.varsize('im_bin');
for idx=1:dim_X
for idy = 1:dim_Y
if (im(idx,idy) < threshold)
im_bin(idx,idy) = 0;
else
im_bin(idx,idy) = 1;
end
end
end
[label, nblabel] = bwlabel(im_bin, 4);
採用された回答
MathWorks Support Team
2019 年 5 月 16 日
編集済み: MathWorks Support Team
2019 年 5 月 16 日
A possible cause of this error message Dynamic Memory Allocation During Code Generation is disabled. Please check the coder configuration to see if something similar to the following segment exists:
cfg = coder.config();
cfg.DynamicMemoryAllocation = 'Off';
codegen -config cfg ...
Replacing "Off" with one of the other choices for "DynamicMemoryAllocation" will avoid the issue.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!