matlab - Checking equality of vector elements -


say have following vectors in matlab:

v1=[2 2 2 2 2 2 2]  v2=[2 2 2 2 3 2 2] 

how can check elements in each vector equal or not?

edit (note)

i'm not asking comparing 2 vectors each other, elements inside each vector together. example, v1 has elements equal each other, while v2 not.

thanks.

length(unique(v1)) == 1  >> 1  length(unique(v2)) == 1  >> 0 

to exclude number don't want include here, e.g 0 in example:

v3=[2 2 2 2 2 2 2 0] length(unique(v3(v3 ~= 0))) == 1 >> 1 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -