Help... what is my mistake and what should i do now?? please

1 次查看(过去 30 天)
function too_young = under_age(age, limit)
if age < limit
too_young = true;
else
too_young = false;
return
end
if age < 21
too_young = true;
end

采纳的回答

madhan ravi
madhan ravi 2020-9-25
Since you have shown efforts:
too_young = under_age(2, []) % [] means no limit was given
function too_young = under_age(age, limit)
if isempty(limit)
limit = 21;
else
limit = limit;
end
too_young = age < limit;
end
  3 个评论
madhan ravi
madhan ravi 2020-9-25
function too_young = under_age(varargin)
if nargin < 2
age = varargin{1};
limit = 21;
else
age = varargin{1};
limit = varargin{2};
end
too_young = age < limit;
end

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by