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 126080Error 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