Var is a double. Change var m to int m. me() is a macro that accesses elements of a matrix, so int is necessary.