daifeng x = 1 x_mat = matrix(1,1,3) class(x) == 'numeric' class(x_mat) == 'matrix' 我现在的写法如上,但是如果x不是numeric就会出错;请问有没有更好的写法呢?