Why do I get the error "Computed maximum size is not bounded" when using colon operator with unbounded arguments in MATLAB Coder?
Afficher commentaires plus anciens
The following code snippet, which initializes an array 'rowIndex' with the colon operator:
assert(all(size(values) == [5,5]),'size mismatch');
[nx,ny] = size(values);
for this_row = 1:nx
start_row = this_row -1;
end_row = this_row + 1;
if start_row == 0 % row 1
start_row = 1;
elseif end_row > nx % row 5
end_row = nx;
end
rowIndex = start_row:end_row;
end
causes MATLAB Coder to throw the error:
??? Computed maximum size is not bounded.
Static memory allocation requires all sizes to be bounded.
However, I do not receive an error when using 'linspace' as shown below:
assert(all(size(values) == [5,5]),'size mismatch');
[nx,ny] = size(values);
for this_row = 1:nx
start_row = this_row -1;
end_row = this_row + 1;
if start_row == 0 % row 1
start_row = 1;
elseif end_row > nx % row 5
end_row = nx;
end
numelRow = end_row-start_row + 1;
assert(numelRow <= 5);
rowIndex = linspace(start_row,end_row,numelRow);
end
Why does the error occur? (Assume that the coder.config setting 'DynamicMemoryAllocation' is set to 'Off')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!