2
$\begingroup$

I am trying to draw a time vs. position graph with these data:

t = {0, 0.47, 0.92, 1.37 ,1.8, 2.21} 
p = {0 ,11.3, 4.2, 10.5, 5, 9.5}

But since the data does not describe a regular sine curve, I do not know how to find the best fit.

I will be super appreciative if anyone can help me to resolve this problem.

$\endgroup$

1 Answer 1

2
$\begingroup$
data = {{0, 0}, {.47, 11.3}, {1.37, 4.2}, {1.8, 5}, {2.21, 9.5}};

dataplot = ListPlot[data, Joined -> True];

nmf = NonlinearModelFit[data, {b + c  Sin[d t + g]}, {b, c, d, g}, t];

modelplot = Plot[nmf[t], {t, 0, 2.21}, Style->Red];

Show[dataplot,modelplot]

enter image description here

$\endgroup$
4
  • $\begingroup$ Is it possible to plot something like sine graph but diminishing at the end? Like a wave. $\endgroup$
    – user193754
    Oct 18, 2019 at 21:41
  • $\begingroup$ @user193754: You must specify the functional form you seek to fit. Otherwise we're just wasting time here. $\endgroup$ Oct 18, 2019 at 21:58
  • $\begingroup$ $\sin\omega t\cdot c^t+C$ $\endgroup$
    – user193754
    Oct 18, 2019 at 22:29
  • 1
    $\begingroup$ @user193754: You should be able to see from my solution how to generalize to what you need. You're on your own now! $\endgroup$ Oct 18, 2019 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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