match time stamps index

michael scheinfeild · Mar 18, 2023 · 2K views
Question
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)
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 25, 2026
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

 

100% Run Guarantee 3-Hour Fast-Track Delivery

Need a Custom Version or Complete Simulation for This Problem?

Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.

Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!