returning differences between two matrices

93 ビュー (過去 30 日間)
Zachary Noll
Zachary Noll 2018 年 9 月 13 日
回答済み: Paolo 2018 年 9 月 13 日
I am relatively new to matlab (saw lots of people bashed for asking simple questions..) I need to compare two matrices, and to return true if they are the same. If they aren't identical, I need to have the code return all of the indeces that were not equal:
for instance, I have matrices A = [1,2,3,4,5] and B = [1,2,4,4,5]. I need the code to return either the index of the unequal variable or some other indicating factor.
Thanks!

採用された回答

madhan ravi
madhan ravi 2018 年 9 月 13 日
編集済み: madhan ravi 2018 年 9 月 13 日
Index = find(A~=B)

その他の回答 (2 件)

Matt J
Matt J 2018 年 9 月 13 日
indicator = (A~=B);

Paolo
Paolo 2018 年 9 月 13 日
You can use setdiff:
[~,ia] = setdiff(A,B)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by