# I'm using old matrix in given data and adding user data to add onto old matrix. Example Days(16x1), Location(16x5), LocationID(1x5) and when user inputs a day its supposed to add onto Days, Same with new location and LocationID.

4 views (last 30 days)
Cody Abt on 15 Sep 2019
Answered: Walter Roberson on 15 Sep 2019
My Code at the moment
D2=input('You continue to do research 5 days after the 60th day. Enter the day')
NL=input('Enter the new location ID','s')
I2=input('Enter Ice Data Collected')
Days2=[Days;D2]
LocationID2=[LocationID';NL]
LocationID2'
Ice2=vertcat(Ice,I2)
fprintf('On Day %d, at NL %s, the ice thickness was %0.4f [m]',Days2(D2),LocationID2(NL),Ice2(D2,NL))
I get at the end of this running operation Index exceeds the number of array elements (17).

#### 1 Comment

Walter Roberson on 15 Sep 2019

Walter Roberson on 15 Sep 2019
Days2(D2)
D2 contains day numbers such as 52 and 60, but there are only 16 (before additional data) or 21 (after additional data) of them. For example day number 52 corresponds to row 15. When you index Days2 you need to be indexing according to row number, not according to day number.