MATLAB: Checking if a matrix has all its elements filled with one or not

if statement

Suppose I have a matrix like x = [1 1 1 1 1 1]. Now I have to write a if condition, where I have to check whether "x" contains all its elements as ones or not? How to do that. I searched in matlab's help, but couldn't find any direct "command" like to check such an existence.

Best Answer

variant
all(x)