How to compare values of two vectors?
43 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
giancarlo maldonado cardenas
am 2 Mai 2022
Beantwortet: Star Strider
am 2 Mai 2022
Hello everyone, how can I compare values between 2 vectors? Let me explain, for example I have two vectors:
vec1= [10 20 30 40 50]% transmission
vec2= [10 20 30 40 50 60 70]; % reception
It should show me the following result:
for example 10,20,30,40,50 was transmitted but 10,20,30,40,50,60,70 were received, then the result would be 5 values were sent but 7 values were received, which would be the value 60 and 70.
Any help would be very helpful, thanks in advance.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Mai 2022
vec1= [10 20 30 40 50]; % transmission
vec2= [10 20 30 40 50 60 70]; % reception
difference = setdiff(vec2,vec1) % Use 'setdiff'
differenceidx = ~ismember(vec2,vec1) % Use 'ismember' And Negate The Result
difference = vec2(differenceidx)
Note the order, so that the longer vector would be the first argument and the shorter vector the second argument.
.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu LTE Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!