Isn't the problem obvious?
Your Is is a 4x1 column vector. It only has one column, therefore asking for the 1st element of column 2, 3 and 4 as you do in your D calculation is invalid. All that stems from the fact that you made an assumption that the vector was a row vector and used 2d indexing to access its elements. You would have avoided this problem if you'd used linear indexing since then it doesn't matter if the vector is a row or column:
D = sqrt(Is(2) - Is(1))^2 + (Is(4)-Is(3))^2;
and it's easier to read as well.
Note for better accuracy:
D = hypot(Is(2)-Is(1), Is(4)-Is(3));