# How to find equal values/words between two string vectors?

5 visualizzazioni (ultimi 30 giorni)
Luca Tognetti il 5 Dic 2022
Commentato: Luca Tognetti il 5 Dic 2022
hi, I would need to find a way to comapre two strings vectors and find the equal value/words. Then I need to know in which position are the equal value. I'll post an exmple:
a=[10, 25, V4E, 64, 33];
b=[64, V4E, T2S, 10, 11];
the output i want to obtain is: c= [1, 3, 4]; which is the position of the equal values in the first vector.
if it's possible it would be awsome to have a second row with the value:
c=[1, 3, 4;
10, V4E, 64]
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

David Hill il 5 Dic 2022
a=["10", "25", "V4E", "64", "33"];
b=["64","V4E", "T2S", "10", "11"];
c=find(ismember(a,b))
c = 1×3
1 3 4
d=a(c)
d = 1×3 string array
"10" "V4E" "64"
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Luca Tognetti il 5 Dic 2022
thank you very much!

Accedi per commentare.

### Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by