How to compare the values of 2 arrays vs each other?
Mostra commenti meno recenti
Hi guys, I am a bit of a noob at Matlab. What I want to do is compare the values of two arrays with each other to see what % similar are they? So, basically, if I have array A = (1,2,3,4) and array B = (1,2,5,6)...I would like to compare these two to each other using a function or something, and that function should state (in this case) that they are 50% similar. I would appreciate your help.
Risposta accettata
Più risposte (1)
Muhammad Ali
il 10 Ott 2024
You can simply use the following code to find at which index both arrays have same values.
Example:
same_index = find(array1 == array2);
1 Commento
Walter Roberson
il 10 Ott 2024
This would find locations at which the values were the same, assuming that the two arrays were the same size.
However, the task is to determine " In my example, 1 and 2 appears in both" -- so the order and size of the two arrays can be different.
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!