Matlab coder, cell arrays and intrinsic functions

9 visualizzazioni (ultimi 30 giorni)
Arwel
Arwel il 28 Apr 2017
Hi,
I am trying to use Matlab coder to generate some C, where a cell array of variable size is populated with arrays of doubles. The sizes of the double arrays and the number of cells vary. The following bits of code show a very simple example of the type of thing I'm doing.
The array function that populates the cells is as follows...
function out = myArrayCallFun(numberOfCells)
myCells = cell(1,numberOfCells);
for i = 1:numberOfCells
myCells{i} = myArrayFn();
end
out = myCells;
This calls a separate subfunction 'myArrayFun' as follows...
function out = myArrayFn()
out = zeros(floor(rand*10),1);
for i = 1:length(out)
out(i) = rand;
end
end
I've made 'myArrayFn' to show that the size of the array is not known at build time. This is called with a 'main' as follows...
numberOfCells = 5;
out = myArrayCallFun(numberOfCells)
This all works just fine with coder. However, in the real thing, myArrayFun is actually a Matlab function supplied at run time by the user in order to provide scripting capability, and what I have been trying to do is to make this extrinsic. So the first line of myArrayCallFun becomes
coder.extrinsic('myArrayFn').
When I try to compile this, I get an error
Code generation does not support mxArrays inside cell arrays.
Is there a possible workaround that I can use here??
Cheers,
Arwel

Risposte (0)

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by