No, they should be single values. You are writing over all of the variables each iteration of your "for j"
overwrites all of x, leaving x of whatever length "year" happens to be.
More typical would be to store into something indexed by your loop variables, such as
x(i, j) = year + 1/2;
y(i, j-1) = monthly_entry;
However, you set monthly_entry to [], which is length 0, for data that is bit-for-bit identical to whatever MATLAB happens to interpret -99.99 as being this time around, a match that would be rare but would occur by accident from time to time. (I already told you about this code being incorrect.) If that ever does happen, you would be unable to store the length-0 [] into the length-1 y(i,j-1)
Your handling of bad data is not well defined. I would suggest to you that your handling would be considerably better defined if you used NaN or 0 for those cases instead of trying to leave a hole in the data.
Best Answer