필터 지우기
필터 지우기

Two vectors different from each other at least at two points

조회 수: 1 (최근 30일)
asim nadeem
asim nadeem 2018년 10월 6일
편집: jonas 2018년 10월 7일
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에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by