0
$\begingroup$

Consider a list as

list = {1, 2, 3, 5, 8, 5};

If I apply interpolation on it,

f = ListInterpolation[{1, 2, 3, 5, 8, 5}];

Edit 1: Now I wish to add two values in between any two consecutive elements such that the new list becomes

  list1 = {1, N@f[4/3], N@f[5/3], 2, N@f[7/3], N@f[8/3], 3, N@f[10/3], 
  N@f[11/3], 5, N@f[13/3], N@f[14/3], 8, N@f[14/3], N@f[13/3], 5}

I tried the following:

f1 = DeleteDuplicates[
  Flatten[Table[
    Table[InverseFunction[f][i], {i, list[[j]], list[[j + 1]], 
      0.33}], {j, 1, Length@list - 1}]]]

However, it's not giving me the desired output.

How can I do this?

$\endgroup$
  • $\begingroup$ Could you describe more precisely what you mean with I wish to add two values in between any two consecutive elements? $\endgroup$ – anderstood Apr 4 '18 at 14:58
  • 1
    $\begingroup$ list2 = f /@ Range[1, Length[list], 1/3] /. x_Rational :> N[x] $\endgroup$ – Bob Hanlon Apr 4 '18 at 15:30
  • $\begingroup$ @BobHanlon Thanks. $\endgroup$ – Majis Apr 4 '18 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.