Check for coordinate pairs matches in .mat file
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
rbharrs
il 25 Ott 2021
Commentato: Star Strider
il 25 Ott 2021
I have a .mat file with with four variables : target, time, x and y. Given a pair of x and y detection on a object tracker, I want to check if the pair appears in the file. How do I iterate through this variable to find a matching pair? I don't need the index, just a true of false of whether the match exists or not.
Pseudocode:
load .mat file
isAMatch = -1
if exist(x,y)
isAMatch = 1
else
isAMatch =0
end
0 Commenti
Risposta accettata
Star Strider
il 25 Ott 2021
List = randi(9, 10, 2)
toMatch = randi(9, 1, 2)
matchedRows = ismember(toMatch, List, 'rows')
numberMatched = nnz(matchedRows)
.
1 Commento
Star Strider
il 25 Ott 2021
My pleasure!
Probably something like this (since I have no idea what the data are) —
yourMatrix = randi(9,10,4)
toMatch = yourMatrix(:,[1 2])
This should work without changing anything other than the ‘yourMatrix’ variable name in ‘toMatch’.
.
Più risposte (1)
Ive J
il 25 Ott 2021
Assuming both x and y are vectors of same length, this might work:
x = randi([0 5], 10, 1);
y = randi([0 5], 10, 1);
myPairedXY = [2 3]; % i.e. x == 2 and y == 3
isMatched = any(x == myPairedXY(1) & y == myPairedXY(2))
0 Commenti
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!