match time stamps index

2 次查看(过去 30 天)
hi i have two vectors diffrent lengths with diffrent values
i want to match closest index in one vector to other
example :
v1 =
[1610759986514 1610759986549 1610759986583 1610759986618 ]
v2= [ 1610759986540 1610759986589]
so result should be in vector 1 match index 2,3 to v2 index 1,2 (time is close enough)

采纳的回答

Walter Roberson
Walter Roberson 2021-1-18
编辑:Walter Roberson 2021-1-25
format long g
v1 = [1610759986514 1610759986549 1610759986583 1610759986618 ]
v1 = 1×4
1610759986514 1610759986549 1610759986583 1610759986618
v2 = [1610759986540 1610759986589]
v2 = 1×2
1610759986540 1610759986589
interp1(v1, 1:length(v1), v2, 'nearest', 'extrap')
ans = 1×2
2 3
interp1(v2, 1:length(v2), v1, 'nearest', 'extrap')
ans = 1×4
1 1 2 2

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by