Variable cell array size for mex function does not work
3 views (last 30 days)
Show older comments
Hey,
I' am trying to bypass the 32bit limit of the MatLab coder, so I chunked my matrix into pieces and wnt to give that pieces into my function. Those subatrizes are arrays within a cell.
Depending on the size of the original matrix, the number of pieces varies, but I am unable to tell MatLab Coder so.
I tried:
coder.varsize('data{:}', [1 20]);
coder.varsize('data', [1 20]);
but both did not work. In coder when I declare the dimensions of the input variables I cant change the value of the cell array dimension.
My trial code looks like:
nums=7000;
cut_limit=5000;
adjacend_matrix=false(nums);
adjacend_matrix(1:nums+1:end)=true;
if length(adjacend_matrix)>=cut_limit
parts=ceil(length(adjacend_matrix)/cut_limit);
cropdata=adjacend_matrix(:,1:cut_limit*(parts-1));
newdata = mat2cell(cropdata, repelem(length(adjacend_matrix),1),repelem(cut_limit,parts-1));
coder.varsize('newdata{:}', [20 1]);
coder.varsize('newdata', [20 1]);
newdata{parts,1}=adjacend_matrix(:,(parts-1)*cut_limit+1:end);
else
newdata = mat2cell(adjacend_matrix, length(adjacend_matrix), length(adjacend_matrix));
end
testvarstrcut(newdata,cut_limit,nums);
I dont use the cell function, which coud be a limitation according to https://de.mathworks.com/help/releases/R2018a/coder/ref/coder.varsize.html?s_tid=doc_ta#btxep35-2
(unless mat2cell counts as "the" cell function). Maybe the problem is that according to limitations declaration must follow the first assignment, which is impossible using mat2cell.
Could someone tell me how to manage it that a mex function would accept newdata as input indepenenden on how many arrays are within it?
Many thanks in advance
Best regards
1 Comment
Raghu Boggavarapu
on 26 Nov 2021
MATLAB Coder does not support changing the size/dimensions of cell array at runtime.
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!