Function With varargin Argument That Can Be Compiled With codegen
이전 댓글 표시
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB Coder에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!