Generate row vectors that match indexes

4 views (last 30 days)
Happy Bear
Happy Bear on 6 Feb 2020
Commented: Happy Bear on 6 Feb 2020
I have a 1x3 vector with the following values: 0.03 0.06 0.11 and another 1x3 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.

Sign in to comment.

Accepted Answer

Rik on 6 Feb 2020
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];
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.
  1 Comment
Happy Bear
Happy Bear on 6 Feb 2020
Thank you so much, exactly what I needed!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!