Effacer les filtres
Effacer les filtres

Lookup values in a table and copy a corresponding value in another table

12 vues (au cours des 30 derniers jours)
Hi,
I have 2 tables, 1 containg the data 'E' (data.mat in this case 2 columns lap and time) and 1 containing the laps for which I'm interested to get the time values from the 1'st table called 'Find'. In essence, I'm looking for something similar to a look up function for this which will write the the coresponding values in a new column in the 'Find' table.
Thanks.

Réponse acceptée

Atsushi Ueno
Atsushi Ueno le 18 Août 2022
load data
load find
E
E = 10×2 table
Lap Time ___ ____ 1 0 2 10 3 15 4 20 5 30 6 40 7 50 8 60 9 70 10 90
Find
Find = 4×1 table
Lap ___ 1 3 7 10
[tf, rows] = ismember(Find,E(:,1))
tf = 4×1 logical array
1 1 1 1
rows = 4×1
1 3 7 10
table(rows, E.Time(rows),'VariableNames',{'FoundLap','Time'})
ans = 4×2 table
FoundLap Time ________ ____ 1 0 3 15 7 50 10 90

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by