There seems to be some confusion about which variables are character arrays and which are doubles. For instance, in this line:
if Testdate(7)<1 || ~ischar(year)==1 || isempty(year)==1 || (length(year)~=4) || year<0
Testdate(7) is a character, and year is a double. In the first comparison (Testdate(7)<1), you are comparing a character with the double 1, which compares the ASCII codes, which is probably not what you want to be doing (in particular the ASCII code for '0' is 48 so if Testdate(7) were '0', then Testdate(7)<1 would evaluate to false, since 48 is not less than 1). I think you are intending to check whether the first digit of the year is less than 1, which you can do by checking if year<1000.
Also, note that year comes from str2double, which always returns a scalar value (possibly NaN). Therefore, ischar(year) will always be false (because year is a double), isempty(year) will also always be false (because year is a scalar), and length(year)~=4 will always be true (because year is a scalar). Also note that length(yearstr) will always be 4 by construction (since yearstr = Testdate(7:10) is always 4 characters long).
So maybe the following check would be sufficient to test for a valid year:
if isnan(year) || year < 1000
Similarly, the checks with isempty(month), ischar(month), length(month), isempty(day), isnumeric(day), are unnecessary or redundant. Since they all come from str2double, they are guaranteed to be scalar doubles, so you only need to check for NaN and check that the value is in an appropriate range.