Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Please what is wrong with this code?

조회 수: 2 (최근 30일)
Ajay Raineni
Ajay Raineni 2020년 4월 7일
마감: MATLAB Answer Bot 2021년 8월 20일
Write a function called valid_date that takes three positive integer scalar inputs year, month, day. If these three represent a valid date, return a logical true, otherwise false. The name of the output argument is valid. If any of the inputs is not a positive integer scalar, return false as well. Note that every year that is exactly divisible by 4 is a leap year, except for years that are exactly divisible by 100. However, years that are exactly divisible by 400 are also leap years. For example, the year 1900 was not leap year, but the year 2000 was. valid = valid_date(2018,4,1) valid = valid_date(2018,4,31)
  댓글 수: 6
Ajay Raineni
Ajay Raineni 2020년 4월 7일
inputs valid =valid_date(2018,4,1) valid = valid_date(2018,4,31) valid= valid_date(2025,6,-8)
Geoff Hayes
Geoff Hayes 2020년 4월 7일
Ajay - don't lines like
if month == 1 3 5 7 8 10 12;
cause an error for you? You probably want to replace with something similar to
if ismember(month, [1 3 5 7 8 10 12])
I strongly suggest that you use the MATLAB debugger to step through the code while the function is running. As you step through each line, ask yourself if what you are trying to do makes sense and that the answer you get is expected.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by