MATLAB Answers

Index exceed number of array elements(1)

7 views (last 30 days)
I am having some trouble as I recieve this error message:
Index exceeds the number of array elements (1).
Error in ERRORT (line 6)
I am also having trouble to ensuring that for both of the if statements have conditions that if the value is left blank it results in the message and also if the month or year is not a number results in the presented message.
Any suggestions?


the cyclist
the cyclist on 2 Jul 2020
What is the value of Testdate that you used as input, for which you got this error?
Alexandra Philip
Alexandra Philip on 2 Jul 2020
Testdate=input('What is the test date?(dd-mm-yyyy)','s')

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 2 Jul 2020
In your function, the input is a character array, but you convert it to a string. The expression
would have pulled out the year, but Teststr is a 1-element string (not a length-10 character array), so you cannot access it like that. So, you either need to pull the year out of the character array:
or do something like this on the string:


Sign in to comment.

More Answers (0)

Translated by