Two vectors different from each other at least at two points

1 次查看(过去 30 天)
I want to compare two vectors and check whether they are different at least at two coordinates.

采纳的回答

jonas
jonas 2018-10-6
编辑:jonas 2018-10-6
sum(abs(V1-V2)~=0)>=2
Will output 1 if they differ at two or more indices. You may want to set a tolerance if they are floating point numbers.
tol=0.01
sum(abs(V1-V2)>tol)>=2
  2 个评论
asim nadeem
asim nadeem 2018-10-7
Thanks how can apply it on the rows of a matrix . I want to check if any two row vectors of a matrix satisfy this condition
jonas
jonas 2018-10-7
编辑:jonas 2018-10-7
If you remove the sum, then you will be left with a logical array where 1 represent indices with differing values. You can for example use
find(abs(V1-V2)>tol)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by