How do I make a condition statement for an element that presents in two different arrays but is at the wrong position? This also applies to more than one elements
1 回表示 (過去 30 日間)
古いコメントを表示
final_code_make = [5 2 3 1]
final_code_guess = [ 1 3 2 4]
As it appears, there are few same elements in both arrays but the arrangement is wrong
2 件のコメント
James Tursa
2021 年 11 月 17 日
編集済み: James Tursa
2021 年 11 月 17 日
It is not clear what you want. Do you want to find out if there are elements common to both arrays? Do you want to find the entire subset of common elements? Do you want to find the positions in both arrays of the common elements? Or ...? What would be the desired output of your example?
回答 (1 件)
James Tursa
2021 年 11 月 17 日
Assuming you have already made the check for the correct number in the correct spot, you can use this
ismember(final_code_guess(i), final_code_make)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!