Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help with these MATLAB codes Validate a date values 1 solution submitted (max: 3) | View my solutions Write a function called valid_date that
please help with these MATLAB codes
Validate a date values 1 solution submitted (max: 3) | View my solutions 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. Note that your solution must not contain any of the date related built-in MATLAB functions Function Reset I MATLAB Documentation function [valid] = valid_date(year, month, date) 5 %check for leap year if year is leap year 6 %'is_leap_year' is set 'l' else '' 7 8 if( mod (year, 4) == 0 && mod(year, 100)=0) 9 is_leap_year=1; 10 else 11 is_leap_year=0; 12 end 13 %------check for months with 31 days 14 if any (month-=[1 3 5 7 8 10 12]) 15 valid = (date>=0 && date=0 && date=0 && date-&& dateStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started