Specify Number of Input or Output Arguments to Entry-Point Functions
If your MATLAB® code takes more inputs or produces more outputs than you want to appear in the generated code, you can instruct the code generator not to generate code for the unneeded arguments.
Control Number of Input Arguments
Consider these functions, both of which support a flexible number of input arguments:
function [x,y] = myops1(varargin) %#codegen if (nargin > 1) x = varargin{1}+varargin{2}; y = varargin{1}*varargin{2}; else x = varargin{1}; y = -varargin{1}; end
function [x,y] = myops2(a,b) %#codegen if (nargin > 1) x = a+b; y = a*b; else x = a; y = -a; end
To generate a function that takes only one
argument, provide one argument to fiaccel
by using
-args
.
fiaccel myops1 -args {fi(3, 1, 16, 13)} -report
fiaccel myops2 -args {fi(3, 1, 16, 13)} -report
Control Number of Output Arguments
When you use fiaccel
,
you can specify the number of output arguments by using the -nargout
option.
Consider these functions:
function varargout = myops3(a,b) %#codegen varargout{1} = a+b; varargout{2} = a*b; varargout{3} = a/b; varargout{4} = a-b; end
function [output1,output2,output3,output4] = myops4(a,b) %#codegen output1 = a+b; output2 = a*b; output3 = a/b; output4 = a-b; end
To generate a function that outputs only
one argument, specify one output argument by using the -nargout
option with the fiaccel
function.
fiaccel myops3 -args {fi(3,1,16,13),fi(3,1,16,13)} -nargout 1 -report
fiaccel myops4 -args {fi(3,1,16,13),fi(3,1,16,13)} -nargout 1 -report
See Also
fiaccel
| varargin
| varargout