How to check if all of the elements in an array are the same, in matlab?

后端 未结 4 1965
粉色の甜心
粉色の甜心 2020-12-09 02:07

There must be a simple matlab way of doing this. I have a row vector and I want to check if all of the elements are equal. Brute forcing this in a loop is easy, but lookin

4条回答
  •  失恋的感觉
    2020-12-09 02:14

    I think it can be as simple as

    if all(v == v(1))
    

    Another method would be

    if range(v) == 0
    

提交回复
热议问题