MATLAB: How to combine data with repeating groups of values

duplicate valueweek numberweekly averageweeknum

Okay, so I have an array called weekNumber. The array was made by taking hourly dates and assigning a week number. (In other words, weekNumber is the weekNumber of hourly date strings.)
An example of the data in weekNumber is:
weekNumber = [53;53;53;53;1;1;1;1;1;1;2;2;2;2;]
What I want to do is combine any repeated values so that weekNumber looks like this:
weekNumber = [53; 1; 2;]
I can do this using:
[sorted,idx] = sort(weekNumber);
[~,ij] = unique(sorted,'first');
Indx = (sort(idx(ij)));
However, my week number data extends back for three years and my code attempts to combine weeknumbers from different years.
For example, week number 53 from year 2011 and week 53 from year 2012 will be combined.
I don't want this to happen!
I want to combine week numbers from there respective years only. I want the range of week numbers containing week x in year y to be combined.
A clear example of what I mean is as follows:
whatIHave = [1;1;1;2;2;2;3;3;3;4;4;4;2;2;2;1;1;1;5;5;5;2;2;2;2;1;1;1;1;]
whatINeed = [1;2;3;4;2;1;5;2;1;]
Can someone please help?
I had difficulty explaining my problem so if you are confused, just ask and I will try to clarify.

Best Answer

So you want the first weekNumber of every week? You can use diff.
whatINeed = weekNumber([true; diff(weekNumber) ~=0])