Function With varargin Argument That Can Be Compiled With codegen
Show older comments
Hi Community,
What is the recipe to defining a function with a varargin argument that can be compiled with codegen?
Here is my example that doesn't work:
function test_functionArgument_varargin(varargin) %#codegen
assert( all(size(varargin)<= [1 , 3])); assert(isa(varargin, 'cell' ));
number = double(varargin{1});
string = varargin{2};
disp(number);
disp(string);
end
And this is an example of the function's call output (without compiling the function):
test_functionArgument_varargin(1,"AAAA",55)
Executing
codegen test_functionArgument_varargin
produces these errors that have a quite cryptic message at least to me:
Type Function Line Description
1 test_functionArgument_varargin 4 Varargin contains zero elements; element 1 is requested.
2 test_functionArgument_varargin 5 Varargin contains zero elements; element 2 is requested.
3 test_functionArgument_varargin 7 Undef. function or variable 'number'. The first assignment to a local variable determines its class.
4 test_functionArgument_varargin 8 Undefined function or variable 'string'. The first assignment to a local variable determines its class.
5 test_functionArgument_varargin 5 varargin and varargout are not supported here.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Coder 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!