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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Argument Definitions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!