Angular Input Validation While Loops Matlab