MATLAB: Import tool in r2015a not working like r2014a for excel spreadsheet import as matrix

bugdatenumdatetimeimporting excel dataMATLAB and Simulink Student Suiter2014ar2015a

Hi, I'm having a hardtime importing excel spreadsheet with dates into matlab r2015a – something that worked perfectly for me in r2014a. I used the same code I've been using for imports but r2015a is giving me errors. the import function I have is:
if true
function data = importdata(workbookFile, sheetName, range)
%IMPORTFILE1 Import data from a spreadsheet
% DATA = IMPORTFILE1(FILE) reads all numeric data from the first sheet
%%Input handling
% If no sheet is specified, read first sheet
if nargin == 1 || isempty(sheetName)
sheetName = 1;
end
% If no range is specified, read all data
if nargin <= 2 || isempty(range)
range = '';
end
%%Import the data, extracting spreadsheet dates in MATLAB serial date number format (datenum)
[~, ~, raw, dateNums] = xlsread(workbookFile, sheetName, range, '', @convertSpreadsheetDates);
raw(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),raw)) = {''};
%%Replace date strings by MATLAB serial date numbers (datenum)
R = ~cellfun(@isequalwithequalnans,dateNums,raw) & cellfun('isclass',raw,'char'); % Find spreadsheet dates
raw(R) = dateNums(R);
%%Replace non-numeric cells with NaN
R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),raw); % Find non-numeric cells
raw(R) = {NaN}; % Replace non-numeric cells
%%Create output variable
data = reshape([raw{:}],size(raw));
end
In r2015a, I tried this function with a 150×9 spreadsheet with Timestamp in first column and it worked well until I tried to import a 126080×9 spreadsheet with the same timestamp in column 1 and I get this error:
if true
All of the input arguments must be of the same size and shape.
Previous inputs had size 1055 in dimension 1. Input #3 has size 126080
Error in importdata (line 41)
R = ~cellfun(@isequalwithequalnans,dateNums,raw) & cellfun('isclass',raw,'char');
end
I have checked the size of dateNums and raw and they appear not to have the same size. I don't understand why when it worked perfectly on r2014a. Thanks anyone that could help me.

Best Answer

I think this might be a bug in reading files with more than a certain number of lines from Excel (5k or 10k, I forget) in the generated code that have a date/time in them. It's bit me a few times but doesn't seem to be in the R2015b prerelease.
As a workaround, use readtable directly.