expand this code to make timeVec from 1951 to 2021 just for 6th month to 9th month for…
- User
expand this code to make timeVec from 1951 to 2021 just for 6th month to 9th month for every year. "% Define the start and end dates startDate = datetime('06/01/2021','InputFormat','MM/dd/yyyy'); endDate = datetime('09/30/2021','InputFormat','MM/dd/yyyy');
% Create the date range and hours dateRange = startDate:endDate; hours = 1:24;
% Create the time vector timeVec = []; for d = 1:length(dateRange) timeVec = [timeVec; dateRange(d)+hours'/24]; end"
- Assistant
% Define the start and end years startYear = 1951; endYear = 2021;
% Create the time vector timeVec = []; for year = startYear:endYear startDate = datetime(sprintf('06/01/%d', year),'InputFormat','MM/dd/yyyy'); endDate = datetime(sprintf('09/30/%d', year),'InputFormat','MM/dd/yyyy'); dateRange = startDate:endDate; hours = 1:24; for d = 1:length(dateRange) timeVec = [timeVec; dateRange(d)+hours'/24]; end end