The regexp for matlab size() is not correct. Parenthesis should be exclude in A:B...case Also [m,n] = size() leads to non-declaration error. fix these.