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
Afficher commentaires plus anciens
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 commentaires
Geoff Hayes
le 20 Août 2020
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
le 20 Août 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!