Cody

Problem 43275. calculate the day of the year from a date string.

Solution 3046924

Submitted on 3 Oct 2020 by Klap Hest
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
start = '09-Oct-2016'; for i = 1:10 date = datestr(datenum(start) + i); doy_correct = 283 + i; doy = dayoftheyear(date); assert(isequal(doy, doy_correct)); end start = '04-Oct-1937'; for i = 1:10 date = datestr(datenum(start) + i); doy_correct = 277 + i; doy = dayoftheyear(date); assert(isequal(doy, doy_correct)); end

ans = 284 ans = 285 ans = 286 ans = 287 ans = 288 ans = 289 ans = 290 ans = 291 ans = 292 ans = 293 ans = 278 ans = 279 ans = 280 ans = 281 ans = 282 ans = 283 ans = 284 ans = 285 ans = 286 ans = 287

Suggested Problems

More from this Author15

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!