No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.7 | 4 ratings Rate this file 6 Downloads (last 30 days) File Size: 1.55 KB File ID: #22663 Version: 1.0



Hallvard (view profile)


Returns the week number(s) corresponding to a vector of serial date numbers.

| Watch this File

File Information

w = weeknum(daynums)
WEEKNUM returns vector W containing the week numbers corresponding to the dates in input vector DAYNUMS of serial date numbers.
Week 1 is the first 4-day week of the year
NB! Using Monday as first day of the week.

Quick and dirty code. No error checking. Use with caution.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
22 Sep 2014 Jesper Stau Stald

Thank you for this tool, very useful!
I discovered a little error, that it will sometimes give the previous week when you give it a full weeknum for a monday.

This seems to be fixed when you floor the datenum, removing all information but the day.

24 Aug 2011 Pieter Schevenels

24 Aug 2011 Pieter Schevenels

29 Nov 2010 Kyriakos

Seems to do what it says on the tin

Contact us