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
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 20 de Ag. de 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
el 20 de Ag. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Variables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!