What you can do instead is:
days_3 = data((days-[100; days(1:end-1)])<0,4)
This checks the difference between each successive value. When the value decreases, it signifies the start of a new month.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!