Is there a way to export functions using Arguments Validation to older MATLAB versions?

2 次查看(过去 30 天)
Greetings,
In version R2020a, MATLAB introduced Function Argument Validation, which allows the coder to pre-define the properties of the input arguments to their function, such as size, class and other limitations, and even set a default value.
The syntax is as follows:
function example(a, b)
arguments
a (1,:) {mustBeNumeric}
b unit32 {mustBeNonNegative} = 3
end
% ...
end
I wanted to find out whether MATLAB has created an option to automatically downgrade those R2020a-syntax functions for campatibility in lower versions, so that the code will look something like:
function example(a, varargin)
if ~isnumeric(a)
error
elseif ~isvector(a)
error
elseif ~isrow(a)
a = a';
end
switch nargin
case 1
b = uint32(3);
case 2
b = unit32(varargin{1});
if b < 0
error
end
otherwise
error
end
% ...
end
Thanks in advance!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by