MATLAB: Generate row vectors that match indexes

matching indexesrowvector

I have a 1×3 vector with the following values: 0.03 0.06 0.11 and another 1×3 vector with the following values: 0.5667 0.7667 0.8667.
Is it possible to generate a row vector of 100 spaced points between 0.03 and 0.01 and another one between 0.5667 and 0.8667? But with the index of 0.06 in the first row vector being the same index of 0.7667 in the second row vector.

Best Answer

The code below will sample points over a parabola, since three points fully determine a second order polynomial. The middle point is guaranteed to match up, but there is no guarantee that the points will be increasing.
v1=[0.03 0.06 0.11];
v2=[0.5667 0.7667 0.8667];
N=6;%set number of elements the output vectors should have
x_short=[0 0.5 1];
x_long=linspace(0,1,N);
if mod(N,2)==0
%With an odd N 0.5 will be in the x vector, but with an even N it will
%not, so change one of the values to 0.5.
x_long(N/2)=0.5;
end
p1=polyfit(x_short,v1,2);
v1_long=polyval(p1,x_long);
p2=polyfit(x_short,v2,2);
v2_long=polyval(p2,x_long);