Hi,
Please note I am new to Matlab and have never written a script.
I have database A with roughly 6x3000 array of strings. I have database B with a similar sized array. Only some of the rows in each database are an exact match. I want to be able to find out which rows in database B match exactly with rows in database A, and then return a yes/no.
E.g.
Database A
"pig" "stripe"
"box" "house"
"apple" "land"
"car" "bus"
"bottle" "rope"
Database B
"car" "sink"
"pig" "stripe"
"land" "car"
"bottle" "rope"
I would want the following return in the order of Database B, so that 0 means its not in Database A, and 1 means it is.
0
1
0
1
Any help GREATLY appreciated.
Thanks
Vicky

Réponses (1)

madhan ravi
madhan ravi le 25 Fév 2019
ismember(Database_B,Database_A,'rows')

4 commentaires

Victoria Fleming
Victoria Fleming le 26 Fév 2019
Thanks - this returns values at the cell level only though.
I need to know if that exact row, is an exact match for a row somehwere in the second database. Is there a way of using ismember to confine to exact matches?
thanks for your help
>> Database_A=...
["pig" "stripe"
"box" "house"
"apple" "land"
"car" "bus"
"bottle" "rope"];
Database_B=...
["car" "sink"
"pig" "stripe"
"land" "car"
"bottle" "rope"];
ismember(Database_B,Database_A,'rows')
ans =
4×1 logical array
0
1
0
1
>>
Where do you see a cell array??
Victoria Fleming
Victoria Fleming le 27 Fév 2019
Hi,
It worked - it returned a value for every cell in the array, but as long as they are all true I can find my matching rows.
Thanks for your help.
madhan ravi
madhan ravi le 27 Fév 2019
Are you asking a question or stating?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by