MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodayGiven an Mx2 vector and a row of M-1 integers, output a two column vector that linearly interpolates Y times between each successive pair of values in X. Any consecutive duplicate points are to be removed.

For example: x=[1 1 ; 3 0 ; 1 1] y=[5 3]

Your output will be a two column vector that interpolates 5 times between [1 1] and [3 0] (including the boundaries in those five points), and then 3 times between [3 0] and [1 1]. The output should be:

1 1 1.5 0.75 2 0.5 2.5 0.25 3 0 2 0.5 1 1

There are Y(1)=5 points between the first two coordinate pairs of X [(1,1) and (3,0)], and Y(2)=3 points between the second and third coordinate pairs of X [(3,0) and (2 0.5)]. Notice that there is only one output point for (3,0).

You can assume that there will be no complex numbers, Inf, or NaN in x, and Y>=3 for all values of Y. Good luck!

18 correct solutions
16 incorrect solutions

Last solution submitted on Mar 28, 2016

2 Comments