Can i give mathworks a tip on the development of MATLAB?

조회 수: 1 (최근 30일)
cui,xingxing
cui,xingxing 2019년 9월 18일
댓글: cui,xingxing 2021년 7월 30일
Many languages have very convenient places, such as python, C / C + + allows custom function parameters default assignment operation, but matlab is "varargin, nargin, inputParser" to control the default assignment operation, more trouble, can be in the new version Add a default function input parameter like python?
for example:
function result = myAdd(a,b,c=1)
result = a+b+c
end
a and b is required param, c is optional param,can matlab new versin add this?

채택된 답변

Guillaume
Guillaume 2019년 9월 18일
편집: Guillaume 2019년 9월 18일
You can suggest whatever you want to mathworks via a service request. Whether or not, they act on it is another matter.
For your particular suggestion, you're in luck this has just been added to R2019b via the arguments block. Not exactly the same syntax as your suggestion, but more flexible anyway:
%R2019b only
function result = myAdd(a, b, c)
arguments
c (1, 1) double = 1
end
result = a+b+c;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Argument Definitions에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by