1
$\begingroup$

I have an external file in extension XLS with looks as follows:

XLS

This file can be obtained by the link below:

Velocidade Angular

With certainty this file is generating a list inappropriate for the utility that I need, because I cannot use its elements in an appropriate manner.

I have attempted to do a test manually to try to obtain some result as follows:

test={{0, -1.90833*10^-14,0},{0.04, -0.0171878,0},{0.08, -0.0683827, 0},{0.12, -0.153032,0},{0.16, -0.270582, 0},{0.2, -0.42048, 0},{0.24, -0.602173,0}};
time=test[[All,1]];
x=test[[All,2]];

Where $x$ are my displacements in axisX and $time$ the time for each one of them.

  1. This would be my first question: what is wrong with this import?

Getting an answer regarding the first question,

  1. I would like to know if I am proceeding in the best way to obtain a polynomial or a function that describes this movement.

    intf = Interpolation[x, time]

I think that I am doing something wrong, for this cause I am not able to evolve my studies.

Information:

Graphics3D[{Red, Line[data], Black, AbsolutePointSize[6],Point[data]}, BoxRatios -> {3, 2, 1.5}, Axes -> True,ImageSize -> 450]

Using the Graphics3D I can obtain an interesting chart, but my goal is to get something that describes this movement mathematically.

enter image description here

$\endgroup$
4
  • $\begingroup$ Your first entry in `test' list missing a zero (third element). You can do Interpolation[test[[All, 1 ;; 2]]] or Interpolation[Transpose[{time, x}]] $\endgroup$
    – demm
    Commented Jun 24, 2016 at 15:12
  • $\begingroup$ You should then try to fit a model to the data or use FindFormula. $\endgroup$
    – demm
    Commented Jun 24, 2016 at 15:27
  • $\begingroup$ Import[file.xls] always returns a list of sheets, even if there is only one sheet, so you need to do data=First@Import[] or similar. This has to be a duplicate. $\endgroup$
    – george2079
    Commented Jun 24, 2016 at 15:41
  • $\begingroup$ seeing the edit, obviously the exact curve is not going to be polynomial, but trigonometric. What exactly are you trying to accomplish? $\endgroup$
    – george2079
    Commented Jun 24, 2016 at 15:47

1 Answer 1

4
$\begingroup$

Import takes all sheets, which nests the data. First@ takes the first sheet formatting the data you need for the subsequent expressions.

test = First@Import["Velocidade Angular.xls"];

time = test[[All, 1]];
x = test[[All, 2]];

f = Interpolation[Transpose[{time, x}], InterpolationOrder -> 3];

Show[
 ListPlot[test[[All, 1 ;; 2]], PlotStyle -> Red],
 Plot[f[t], {t, time[[1]], time[[-1]]}]
 ]

enter image description here

data = Transpose[{time, x}];

model = a + b t + c t^2 + d t^3;

pos = NonlinearModelFit[data, model, {a, b, c, d}, t]
vel = pos'
acc = pos''

Plot[{pos[t], vel[t], acc[t]}, {t, time[[1]], time[[-1]]}, PlotLegends -> "Expressions"]

pos[t] =-1.0569*^-13 + 9.28177*^-14*t - 10.8*t^2 + 1.44*t^3

vel[t] = 9.28177*10^-14 - 21.6 t +4.32 t^2

acc[t] = -21.6 + 8.64 t

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Since the interpolation is 3rd order the model can be as well. Let me know if the addition above is acceptable. $\endgroup$
    – Young
    Commented Jun 24, 2016 at 15:45
  • $\begingroup$ I added velocity and acceleration to the answer, just in case you have trouble. $\endgroup$
    – Young
    Commented Jun 24, 2016 at 17:01

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.