how to compare two values that are repeated in two vectors?
Ältere Kommentare anzeigen
Hello everyone, I'm new to matlab, I wanted to know how I can compare 2 values that are repeated between two vectors, I'll explain myself better, for example I have these two vectors.
A = [10 56 34 11 34 ];
B = [10 56 34 11 ];
Now I need to compare element by element, I mean...
vector B = [(10) 56 34 11]; element 10 is repeated in vector A? No then it is assigned the number 1.
vector B = [10 (56) 34 11 ]; element 56 is repeated in vector A? No then it is assigned the number 1.
vector B = [10 56 (34) 11 ]; element 34 is repeated in vector A? Yes! then it is assigned the number 0.
vector B = [10 56 34 (11) ]; element 34 is repeated in vector A? Yes! then it is assigned the number 1.
the result has to be an array, equal to this.
result= [10 1
56 1
34 0
11 1]
any help will be very helpful.
2 Kommentare
Image Analyst
am 2 Jun. 2022
Bearbeitet: Image Analyst
am 2 Jun. 2022
What if the numbers are not in the same index in the two vectors, like
A = [10 56 34 11 34 ];
B = [11 10 56 34 5 ];
are the 10, 56, and 34 repeated in B? What's your definition of repeated?
And is this your homework (sounds like it)?
giancarlo maldonado cardenas
am 2 Jun. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu LTE Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!