Index in position 2 exceeds array bounds.(keep appearing this although I tried different arrays)

[tempData,~] =xlsread(rawDataFile,'Sheet1');
releaseCal.refP =x2mdate(tempData(:,1));
releaseCal.releaseDates =x2mdate(tempData(:,2:end));

3 Comments

check the size of x2mdate and the value of tempData(:,1) and ensure tempData(:,1) is the right index value to x2mdate
x2mdate is a matlab command to convert excel date number into matlab date number

Sign in to comment.

Answers (1)

xlsread is obselete. USe readtable.
T = readtable(rawDataFile,'Sheet1');
You can convert it to the array using table2array. You can access any column using T.(1), T.(2), etc. While extracting any column keep the dimensions in mind.

3 Comments

T = readtable('1.xlsx');
A = table2array(T);
releaseCal.refP =x2mdate(A(2:end,1));%reference period
releaseCal.releaseDates =x2mdate(A(2:35,2:end));
NOW MY MATLAB TELLING ME THIS
Error using x2mdate (line 57)
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript.
Because the sheet 1 is an excel consisting of a table of excel dates. try to convert that into matlab date here

Sign in to comment.

Asked:

on 5 Aug 2021

Commented:

on 5 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!