How do I check to see if the elements in a matrix are all equal?

54 次查看(过去 30 天)
So if I have matrix A=[1 1 1 ; 1 1 1 ; 1 1 1] I would like to run a check so check if all the elements in the matrix are the same. Or say matrix B = [1, 0 1; 0 1 0; 1 1 0] I would liek to run a check to see if the elements are all the same ( in this case they aren't).

采纳的回答

madhan ravi
madhan ravi 2020-9-11
a = num2cell(A);
isequal(a{:})

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by