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
显示 更早的评论
hey,
people
The code the I wrote is giving the correct output for some dates but it is not giving the correct output for the date valid_date(1900,2,29).
And i even tried to input non-scalar values and the Run function command is showing valid=0 for non-scalar value then why is it not accepting the answer
2 个评论
Geoff Hayes
2020-8-20
Amit - rather than posting a screen shot of the code, attach it instead so that we can run through it ourselves to help you understand what the problem might be. For the input date of 1900-2-29, I would use the MATLAB debugger to step through the code to see where the valid flag is being set to false and hopefully correct the error at that line. As for the non-scalar input values, please provide some examples of what you mean by this.
Amit Prajapati
2020-8-20
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Variables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!