0
$\begingroup$

I made a force diagram into a matrix. How can I have find a value in y for a number in x? I know for 0.1 for example the force becomes 500, or for 0.3 it becomes -500 How do I know how much it will be for .1234

p = ( {
    {0, 0},
    {.2, 1000},
    {.4, 0},
    {.6, -1000},
    {.8, 0}
   } );
ListLinePlot[p]

enter image description here

$\endgroup$
1
  • $\begingroup$ i use this but it give me wrong answers Interpolation[p, .1] $\endgroup$ Dec 1, 2020 at 17:48

1 Answer 1

1
$\begingroup$
Clear["Global`*"]

p = {{0, 0}, {.2, 1000}, {.4, 0}, {.6, -1000}, {.8, 0}};

Use Interpolation

f = Interpolation[p];

f[0.1234]

(* 962.25 *)

Plot[f[x], {x, 0, 0.8},
 Epilog -> {AbsolutePointSize[6],
   Red, Point[p], Green, Point[{#, f[#]} &[0.1234]]}]

enter image description here

Edit: If you want linear interpolation change the InterpolationOrder to 1

f2 = Interpolation[p, InterpolationOrder -> 1];

f2[0.1234]

(* 617. *)

Plot[f2[x], {x, 0, 0.8}, 
 Epilog -> {AbsolutePointSize[6], Red, Point[p], Green, 
   Point[{#, f2[#]} &[0.1234]]}]

enter image description here

$\endgroup$
5
  • $\begingroup$ that's my problem, my digram is liner not like something you say, in fact I have diagram and I want Interpolation it $\endgroup$ Dec 1, 2020 at 18:04
  • $\begingroup$ tanks a lot, i have jus on more questions ,My steps for t are 0.1 from zero to two. How can I write this formula? c = Subscript[t, i] + Subscript[t, i + 1] c=t(i)+t(i+1) $\endgroup$ Dec 1, 2020 at 18:46
  • $\begingroup$ Your comment doesn't make any sense to me. You have not explained how c or t relates to anything previously discussed. If t is the domain of f, the interval {0.1, 2} extends well beyond the basis for the interpolation (i.e., {0, 0.8}) and would require extrapolation rather than interpolation. If so, what is the expected behavior outside of the origin range? Linear? Periodic? You want to know "how to write a formula" but you have not said what the formula is to represent other than the formula that you gave. Please formulate your question better and post as a new question. $\endgroup$
    – Bob Hanlon
    Dec 1, 2020 at 20:55
  • $\begingroup$ Hi, I said my question has nothing to do with the previous one,Suppose I have this formula t={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10} How to calculate c=t(i)+t(i+1) $\endgroup$ Dec 1, 2020 at 22:13
  • $\begingroup$ New questions should not be asked in comments. $\endgroup$
    – Bob Hanlon
    Dec 1, 2020 at 22:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.