Why do I get the MATLAB Coder error 'Computed maximum size exceeds maximum allowed number of elements' when calling 'sum' on an array?
Show older comments
When using MATLAB Coder in MATLAB R2023b to generate from the following code:
definitionA = coder.typeof(double(1),[2272, 16, 2, 16],[1 1 1 1]);
parameterA = coder.typeof(definitionA);
with 'DynamicMemoryAllocation' set to 'Off', I encounter the following error:
Computed maximum size exceeds maximum allowed number of elements (134217728).
The computed size is [:2272 x :16 x :2272 x :16].
According to the error message, it appears the third dimension of 'parameterA' is being expanded to match that of the first dimension.
This behavior can be traced to the 'sum' function on the following line in 'libraryA.m':
n = squeeze(sum(~isnan(parameterA),[2 3]));
Is this behavior expected?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!