I have debugged the code and now the Scalar test for this code is failing although I have given a provition in the 3rd line of the code to check wheather the given inputs are scalar or not.
please help!
function valid = valid_date(year,month,day)if nargin==3 if fix(month) && isscalar(month) && fix(day) && isscalar(day) && fix(year) && isscalar(year) && isscalar(valid_date) && year>0 && month>0 && day>0 if mod(year,4)==0&&mod(year,100)~=0 || mod(year,400)==0&&mod(year,100)==0 if ismember(month,[1,3,5,7,8,10,12]) && ismember(day,[1:31]) valid=true; elseif month==2 && ismember(day,[1:29]) valid=true; elseif ismember(month,[4,6,9,11]) && ismember(day,[1:30]) valid=true; else valid=false; end else if ismember(month,[1,3,5,7,8,10,12]) && ismember(day,[1:31]) valid=true; elseif ismember(month,[4,6,9,11]) && ismember(day,[1:30]) valid=true; elseif month==2 && ismember(day,[1:28]) valid=true; else valid=false; end end else valid=false; endelsevalid=false;end
Assessment result: correctVarious inputs Assessment result: incorrectNon-scalarReturn false if an input is not scalar... Assessment result: correctThe last day of every month Assessment result: correctRandom leap years Assessment result: correctRandom non-leap years Assessment result: correctRandom dates
Best Answer