Which lines between two vectors are not equal?

조회 수: 3 (최근 30일)
Dylan Mecca
Dylan Mecca 2018년 3월 6일
댓글: Walter Roberson 2018년 3월 7일
Hi everyone,
I am looking at two vectors, and I want matlab to tell me at which lines they two vectors are not equal. I will attach two sample columns of 0's and 1's. For example, the csv file I've uploaded is NOT equal at (4:7,:) and (14:15,:). How can I have matlab return that information to me?
Thanks in advance!

채택된 답변

Walter Roberson
Walter Roberson 2018년 3월 6일
data(:,1) ~= data(:,2)
??
  댓글 수: 2
Dylan Mecca
Dylan Mecca 2018년 3월 6일
Is there a way to have it display the rows it applies to? In this example, would it be possible to have matlab also return the line it is true for? Like I mentioned in my question, can we display lines (4:7,:) and (14:15,:).
Walter Roberson
Walter Roberson 2018년 3월 7일
If you want the row numbers displayed with the rows:
idx = find(data(:,1) ~= data(:,2));
[idx(:), data(idx,:)]
If you just want the contents of the rows:
data(data(:,1) ~= data(:,2), :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by