MATLAB: Does XLSREAD not replace empty cells by ‘NaN’ when the cells appear at the end of the range in MATLAB 7.5 (R2007b)

excelMATLABnan

I am using the following syntax to use XLSREAD:
num = xlsread(filename, 'range')
I have 20 rows of numeric data in an excel sheet and I am specifying the range until 21st row. The last row is empty.
When I use XLSREAD to read the data, the last row is trimmed and it returns only 20 rows in MATLAB. Whereas if a middle row is empty, lets say, 12th row, the elements are filled by 'NaN'. Hence, in the first case also, the 21st row should have been appended to a row of 'NaN's.

Best Answer

XLSREAD is deisnged to trim any empty trailing rows and columns specfied in the range. The matrix returned by XLSREAD can easily be grown in MATLAB to include an additional row or column of NaNs, as shown below:
num = xlsread(filename, 'range');
[m n] = size(num);
num(end+1,:) = nan(1,n);