function result = ordinalDay(m,d,y) %ordinalDay returns the number of this day in the year % % consumes: % m (scalar number), the month as a number % jan = 1, feb = 2, etc. % d (scalar number), the day of the month % % y (scalar number), the year % % Note: year is needed because of leap years. % % year is leap year if divisible if % (year is not divisible by 100 and year is divisible by 4) % OR % (year is divisble by 400) % % examples: % >> ordinalDay(1,1,2006) % ans =1 % >> ordinalDay(2,1,2006) % ans = 32 % >> ordinalDay(3,1,2006) % ans = 60 % >> ordinalDay(3,1,2004) % ans = 61 % >> ordinalDay(12,31,2006) % ans = 365 % >> ordinalDay(12,31,2000) % ans = 366 % >> ordinalDay(12,31,1900) % ans = 365 % a clue.. start by defining this daysPerMonth = [31 28 31 30 31 30 31 31 30 31 30 31]; % then use d, m and y to calculate result % since this is a "stub", for now we always return 0 result = 0 ; return; end