MATLAB: Importdata skips the last few rows

data importMATLAB

Hello all. I was using importdata in my code to bring in some matrices. I hadn't tested the code in quite some time, but I just upgraded from r2011a to r2012a and then ran it. Apparently importdata is now misbehaving. Whenever I try to do
>> data = importdata('file.txt')
where file.txt is a 360×720 ASCII file (generated from Matlab a while back using
>> save('file.txt','variable','-ASCII')
I get a variable that is 348×720:
>> size(data)
ans =
348 720
This happens with other 360×720 ASCII files as well, although for some of them I only get 347 rows. What do you think is going on? Thanks in advance!
PS: Here is a link to an example 'file.txt' this happens with.

Best Answer

That's odd... Confirmed in my own 2012a.
It appears to be trimming all the entirely NaN rows from the end of your data.
I replaced line 348 with line 349, and confirmed the result is 347 rows long. Then I set the first element in line 360 to a non-nan value, and the result was 360 rows long.
I think this is stupid behaviour to have in a function, but nevermind.
Given that the files were created with save, you should do this instead:
data = load('file.txt', '-ASCII');