Verify a matrix value on MATLAB

前端 未结 3 1123
醉话见心
醉话见心 2021-01-22 05:41

I am using MATLAB. I have a question about how i can verify that the values of a matrix are being repeating, like this:

A=[ 2 3 2 3 2 3 2 3]

If

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-22 06:20

    Here is another simple way to do it:

    AUX = all(A(1) == A(1:2:end)) && all(A(2) == A(2:2:end))
    

    Basically this checks whether all odd elements are equal to the first element, and all even elements are equal to the second element.

提交回复
热议问题