number is overwritten every iteration so it will take on only the value from the last iteration. If it's zero at the end then data(Month(end)) must have been -1. To not overwrite, do
If you need help, attach Month and data
save('Answers.mat', 'Month', 'data');
Use the paperclip icon to attach the .mat file.