Why do I get an error when I create variable sized matrices in Embedded MATLAB in Real-Time Workshop 7.6 (R2010b)?
1 view (last 30 days)
Show older comments
When I try to call the below function:
function z = fcn(u,s) % s =128
%#eml
a = zeros(1,s);
b = zeros(1,s);
c = complex(a,b);
c(1:3) = u;
z = fft(c);
using the function call:
emlmex fcn -eg {zeros(1,3) 128} –report
I get the following error:
??? Computed maximum size is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [1 x :?].
Please consider enabling dynamic memory allocation to allow unbounded sizes.
Error in ==> fcn2 Line: 5 Column: 5
C-MEX generation failed: Open error report.
??? Error using ==> emlmex
Accepted Answer
MathWorks Support Team
on 5 Apr 2012
This bug has been fixed in Release 2012a (R2012a). For previous product releases, read below for any possible workarounds:
The reason for the error is that the '–eg' option does not take the value of the argument, but rather the class and size of each element. Therefore, the arguments
emlmex fcn -eg {zeros(1,3) 0} –report
and
emlmex fcn -eg {zeros(1,3) 128} –report
are identical as function calls because the second element of the cell array is a scalar double in both cases. The fact that the value is different in each case has no bearing whatsoever on the code generation. Since EML uses the data type of the parameter to determine the upper bound on the size of the variable, the double class has a large upper bound. For the purposes of code generation, this number is too big for an upper bound, so EML considers it as unbounded.
The correct function call for the above embedded MATLAB code is:
emlmex fcn -eg {zeros(1,3) uint8(0)} –report
EML now recognizes that the upper bound of the second argument is 255, because 255 is the upper bound of any variable of class uint8. So it is able to figure out that the upper bound on the arrays that are created based on this argument must have an upper bound of 255 also.
0 Comments
More Answers (0)
See Also
Categories
Find more on Debugging and Analysis 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!