MATLAB: Last Sunday in a month

nweekdate

Hi there,
I am trying to identify the datetime of the last Sunday in March and October. I am aware of the nweekdate function but it requires the nth occurence of the day in that month, as an input. Any ideas would be highly appreciated.
Thank you in advance,
Andreas

Best Answer

d = calendar(2013,01) ;
s = d(d(:,1)~=0,1)
s(end)