0
$\begingroup$

i have a problem with finding interpolation function. I have a date like this:

{{0.}, {9.17306*10^-6}, {0.000018338}, {0.0000274865}, \
{0.0000366106}, {0.0000457021}, {0.0000547528}, {0.0000637548}, \
{0.0000727001}, {0.0000815805}, {0.0000903884}, {0.0000991157}, \
{0.000107755}, {0.000116298}, {0.000124737}, {0.000133066}, \
{0.000141276}, {0.00014936}, {0.000157311}, {0.000165122}, \
{0.000172785}, {0.000180295}, {0.000187645}, {0.000194827}, \
{0.000201836}, {0.000208665}, {0.000215308}, {0.000221759}, \
{0.000228013}, {0.000234064}, {0.000239907}, {0.000245535}, \
{0.000250945}, {0.000256132}, {0.00026109}, {0.000265816}, \
{0.000270305}, {0.000274553}, {0.000278557}, {0.000282313}, \
{0.000285817}, {0.000289067}, {0.000292059}, {0.000294792}, \
{0.000297261}, {0.000299466}, {0.000301404}, {0.000303074}, \
{0.000304474}, {0.000305603}, {0.000306459}, {0.000307043}, \
{0.000307353}, {0.000307389}, {0.000307152}, {0.000306641}, \
{0.000305856}, {0.0003048}, {0.000303472}, {0.000301874}, \
{0.000300007}, {0.000297872}, {0.000295473}, {0.00029281}, \
{0.000289886}, {0.000286705}, {0.000283268}, {0.000279578}, \
{0.00027564}, {0.000271456}, {0.000267031}, {0.000262367}, \
{0.00025747}, {0.000252344}, {0.000246992}, {0.000241421}, \
{0.000235635}, {0.000229639}, {0.000223439}, {0.000217039}, \
{0.000210446}, {0.000203666}, {0.000196704}, {0.000189567}, \
{0.000182262}, {0.000174794}, {0.00016717}, {0.000159397}, \
{0.000151483}, {0.000143433}, {0.000135256}, {0.000126959}, \
{0.000118548}, {0.000110031}, {0.000101417}, {0.0000927125}, \
{0.0000839253}, {0.0000750633}, {0.0000661345}, {0.0000571468}, \
{0.0000481082}, {0.0000390267}, {0.0000299105}, {0.0000207677}, \
{0.0000116063}, {2.43463*10^-6}, {-6.73923*10^-6}, {-0.0000159071}, \
{-0.0000250608}, {-0.0000341921}, {-0.0000432931}, {-0.0000523554}, \
{-0.0000613711}, {-0.0000703322}, {-0.0000792306}, {-0.0000880585}, \
{-0.000096808}, {-0.000105471}, {-0.00011404}, {-0.000122508}, \
{-0.000130867}, {-0.000139109}, {-0.000147227}, {-0.000155214}, \
{-0.000163063}, {-0.000170766}, {-0.000178318}, {-0.000185711}, \
{-0.000192938}, {-0.000199993}, {-0.000206871}, {-0.000213564}, \
{-0.000220066}, {-0.000226373}, {-0.000232479}, {-0.000238377}, \
{-0.000244063}, {-0.000249531}, {-0.000254777}, {-0.000259797}, \
{-0.000264585}, {-0.000269137}, {-0.00027345}, {-0.000277519}, \
{-0.000281341}, {-0.000284912}, {-0.00028823}, {-0.000291291}, \
{-0.000294092}, {-0.000296632}, {-0.000298907}, {-0.000300916}, \
{-0.000302657}, {-0.000304129}, {-0.00030533}, {-0.000306258}, \
{-0.000306914}, {-0.000307297}, {-0.000307406}, {-0.000307241}, \
{-0.000306803}, {-0.000306091}, {-0.000305107}, {-0.000303851}, \
{-0.000302324}, {-0.000300528}, {-0.000298465}, {-0.000296135}, \
{-0.000293542}, {-0.000290688}, {-0.000287574}, {-0.000284205}, \
{-0.000280582}, {-0.000276709}, {-0.00027259}, {-0.000268228}, \
{-0.000263628}, {-0.000258792}, {-0.000253726}, {-0.000248434}, \
{-0.000242921}, {-0.000237191}, {-0.00023125}, {-0.000225104}, \
{-0.000218756}, {-0.000212214}, {-0.000205483}, {-0.000198569}, \
{-0.000191478}, {-0.000184217}, {-0.000176791}, {-0.000169208}, \
{-0.000161474}, {-0.000153597}, {-0.000145582}, {-0.000137438}, \
{-0.000129172}, {-0.00012079}, {-0.000112301}, {-0.000103712}, \
{-0.0000950309}, {-0.0000862648}, {-0.0000774219}, {-0.0000685101}, \
{-0.0000595372}, {-0.0000505113}, {-0.0000414405}, {-0.0000323327}, \
{-0.0000231961}, {-0.0000140388}, {-4.8691*10^-6}, {4.30498*10^-6}, \
{0.0000134752}, {0.0000226335}, {0.0000317716}, {0.0000408813}, \
{0.0000499547}, {0.0000589836}, {0.00006796}, {0.0000768758}, \
{0.0000857232}, {0.0000944942}, {0.000103181}, {0.000111776}, \
{0.000120271}, {0.00012866}, {0.000136933}, {0.000145085}, \
{0.000153108}, {0.000160994}, {0.000168737}, {0.000176329}, \
{0.000183765}, {0.000191036}, {0.000198138}, {0.000205063}, \
{0.000211806}, {0.00021836}, {0.000224719}, {0.000230878}, \
{0.000236832}, {0.000242575}, {0.000248101}, {0.000253407}, \
{0.000258487}, {0.000263337}, {0.000267952}, {0.000272329}, \
{0.000276463}, {0.000280351}, {0.000283989}, {0.000287374}, \
{0.000290504}, {0.000293374}, {0.000295983}, {0.000298329}, \
{0.000300409}, {0.000302221}, {0.000303765}, {0.000305037}, \
{0.000306038}, {0.000306767}, {0.000307222}, {0.000307404}, \
{0.000307312}, {0.000306946}, {0.000306307}, {0.000305395}, \
{0.000304211}, {0.000302756}, {0.000301031}, {0.000299038}, \
{0.000296779}, {0.000294256}, {0.00029147}, {0.000288425}, \
{0.000285124}, {0.000281568}, {0.000277761}, {0.000273707}, \
{0.000269409}, {0.000264872}, {0.000260098}, {0.000255093}, \
{0.00024986}, {0.000244405}, {0.000238733}, {0.000232847}, \
{0.000226755}, {0.00022046}, {0.000213969}, {0.000207287}, \
{0.000200421}, {0.000193377}, {0.00018616}, {0.000178777}, \
{0.000171235}, {0.000163541}, {0.000155701}, {0.000147722}, \
{0.000139612}, {0.000131377}, {0.000123025}, {0.000114564}, \
{0.000106001}, {0.0000973433}, {0.0000885989}, {0.0000797756}, \
{0.0000708813}, {0.0000619239}, {0.0000529113}, {0.0000438516}, \
{0.0000347528}, {0.000025623}, {0.0000164705}, {7.30327*10^-6}, \
{-1.87045*10^-6}, {-0.0000110425}, {-0.0000202047}, {-0.000029349}, \
{-0.0000384671}, {-0.0000475509}, {-0.0000565924}, {-0.0000655834}, \
{-0.0000745161}, {-0.0000833824}, {-0.0000921744}, {-0.000100884}, \
{-0.000109504}, {-0.000118027}, {-0.000126445}, {-0.000134749}, \
{-0.000142934}, {-0.000150992}, {-0.000158915}, {-0.000166696}, \
{-0.000174329}, {-0.000181807}}

and i'm link every amplitude with time like this:

For[i = 1; j = 0.001, i < 1600, i++; j = j + 0.001, 
 PrependTo[mod11[[i]], j]]

But i cant get interpolation fuction. Commands FindFormula, FunctionInterpolation or others didnt get any result. In the best case, I would like to find out how you can get the interpolation function using the least squares method. Please, help me.

Update1:

enter image description here

And how could i get function from this?

Plot looks like: enter image description here

$\endgroup$

closed as off-topic by Sascha, Feyre, MarcoB, chuy, m_goldberg Jan 9 '17 at 23:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, chuy, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Try ListInterpolation[Flatten[mod11], {0.001, 0.001 Length[mod11]}] and report back. $\endgroup$ – J. M. is away Jan 9 '17 at 8:48
  • 2
    $\begingroup$ The least-squares method suggests that you have a model function to fit the data. Interpolation would give a piecewise polynomial that passes through each datapoint. Which exactly are you looking for? $\endgroup$ – LLlAMnYP Jan 9 '17 at 8:49
  • $\begingroup$ @LLlAMnYP I think the model function should be ASin[wx]. I want to deal with the two approaches, becouse I want to deal with the two approaches, because I could not do it by any of them $\endgroup$ – YuMo Jan 9 '17 at 8:58
  • 2
    $\begingroup$ Perhaps the error is that you have Sin[wx] when it should be Sin[w x] $\endgroup$ – LLlAMnYP Jan 9 '17 at 10:33
  • 1
    $\begingroup$ Well now you have sin instead of Sin $\endgroup$ – LLlAMnYP Jan 9 '17 at 12:03
3
$\begingroup$

Flatten the amplitude values

amp = {{0.}, {9.17306*10^-6}, {0.000018338}, {0.0000274865}, {0.0000366106}, \
{0.0000457021}, {0.0000547528}, {0.0000637548}, {0.0000727001}, \
{0.0000815805}, {0.0000903884}, {0.0000991157}, {0.000107755}, {0.000116298}, \
{0.000124737}, {0.000133066}, {0.000141276}, {0.00014936}, {0.000157311}, \
{0.000165122}, {0.000172785}, {0.000180295}, {0.000187645}, {0.000194827}, \
{0.000201836}, {0.000208665}, {0.000215308}, {0.000221759}, {0.000228013}, \
{0.000234064}, {0.000239907}, {0.000245535}, {0.000250945}, {0.000256132}, \
{0.00026109}, {0.000265816}, {0.000270305}, {0.000274553}, {0.000278557}, \
{0.000282313}, {0.000285817}, {0.000289067}, {0.000292059}, {0.000294792}, \
{0.000297261}, {0.000299466}, {0.000301404}, {0.000303074}, {0.000304474}, \
{0.000305603}, {0.000306459}, {0.000307043}, {0.000307353}, {0.000307389}, \
{0.000307152}, {0.000306641}, {0.000305856}, {0.0003048}, {0.000303472}, \
{0.000301874}, {0.000300007}, {0.000297872}, {0.000295473}, {0.00029281}, \
{0.000289886}, {0.000286705}, {0.000283268}, {0.000279578}, {0.00027564}, \
{0.000271456}, {0.000267031}, {0.000262367}, {0.00025747}, {0.000252344}, \
{0.000246992}, {0.000241421}, {0.000235635}, {0.000229639}, {0.000223439}, \
{0.000217039}, {0.000210446}, {0.000203666}, {0.000196704}, {0.000189567}, \
{0.000182262}, {0.000174794}, {0.00016717}, {0.000159397}, {0.000151483}, \
{0.000143433}, {0.000135256}, {0.000126959}, {0.000118548}, {0.000110031}, \
{0.000101417}, {0.0000927125}, {0.0000839253}, {0.0000750633}, \
{0.0000661345}, {0.0000571468}, {0.0000481082}, {0.0000390267}, \
{0.0000299105}, {0.0000207677}, {0.0000116063}, {2.43463*10^-6}, \
{-6.73923*10^-6}, {-0.0000159071}, {-0.0000250608}, {-0.0000341921}, \
{-0.0000432931}, {-0.0000523554}, {-0.0000613711}, {-0.0000703322}, \
{-0.0000792306}, {-0.0000880585}, {-0.000096808}, {-0.000105471}, \
{-0.00011404}, {-0.000122508}, {-0.000130867}, {-0.000139109}, \
{-0.000147227}, {-0.000155214}, {-0.000163063}, {-0.000170766}, \
{-0.000178318}, {-0.000185711}, {-0.000192938}, {-0.000199993}, \
{-0.000206871}, {-0.000213564}, {-0.000220066}, {-0.000226373}, \
{-0.000232479}, {-0.000238377}, {-0.000244063}, {-0.000249531}, \
{-0.000254777}, {-0.000259797}, {-0.000264585}, {-0.000269137}, \
{-0.00027345}, {-0.000277519}, {-0.000281341}, {-0.000284912}, {-0.00028823}, \
{-0.000291291}, {-0.000294092}, {-0.000296632}, {-0.000298907}, \
{-0.000300916}, {-0.000302657}, {-0.000304129}, {-0.00030533}, \
{-0.000306258}, {-0.000306914}, {-0.000307297}, {-0.000307406}, \
{-0.000307241}, {-0.000306803}, {-0.000306091}, {-0.000305107}, \
{-0.000303851}, {-0.000302324}, {-0.000300528}, {-0.000298465}, \
{-0.000296135}, {-0.000293542}, {-0.000290688}, {-0.000287574}, \
{-0.000284205}, {-0.000280582}, {-0.000276709}, {-0.00027259}, \
{-0.000268228}, {-0.000263628}, {-0.000258792}, {-0.000253726}, \
{-0.000248434}, {-0.000242921}, {-0.000237191}, {-0.00023125}, \
{-0.000225104}, {-0.000218756}, {-0.000212214}, {-0.000205483}, \
{-0.000198569}, {-0.000191478}, {-0.000184217}, {-0.000176791}, \
{-0.000169208}, {-0.000161474}, {-0.000153597}, {-0.000145582}, \
{-0.000137438}, {-0.000129172}, {-0.00012079}, {-0.000112301}, \
{-0.000103712}, {-0.0000950309}, {-0.0000862648}, {-0.0000774219}, \
{-0.0000685101}, {-0.0000595372}, {-0.0000505113}, {-0.0000414405}, \
{-0.0000323327}, {-0.0000231961}, {-0.0000140388}, {-4.8691*10^-6}, \
{4.30498*10^-6}, {0.0000134752}, {0.0000226335}, {0.0000317716}, \
{0.0000408813}, {0.0000499547}, {0.0000589836}, {0.00006796}, {0.0000768758}, \
{0.0000857232}, {0.0000944942}, {0.000103181}, {0.000111776}, {0.000120271}, \
{0.00012866}, {0.000136933}, {0.000145085}, {0.000153108}, {0.000160994}, \
{0.000168737}, {0.000176329}, {0.000183765}, {0.000191036}, {0.000198138}, \
{0.000205063}, {0.000211806}, {0.00021836}, {0.000224719}, {0.000230878}, \
{0.000236832}, {0.000242575}, {0.000248101}, {0.000253407}, {0.000258487}, \
{0.000263337}, {0.000267952}, {0.000272329}, {0.000276463}, {0.000280351}, \
{0.000283989}, {0.000287374}, {0.000290504}, {0.000293374}, {0.000295983}, \
{0.000298329}, {0.000300409}, {0.000302221}, {0.000303765}, {0.000305037}, \
{0.000306038}, {0.000306767}, {0.000307222}, {0.000307404}, {0.000307312}, \
{0.000306946}, {0.000306307}, {0.000305395}, {0.000304211}, {0.000302756}, \
{0.000301031}, {0.000299038}, {0.000296779}, {0.000294256}, {0.00029147}, \
{0.000288425}, {0.000285124}, {0.000281568}, {0.000277761}, {0.000273707}, \
{0.000269409}, {0.000264872}, {0.000260098}, {0.000255093}, {0.00024986}, \
{0.000244405}, {0.000238733}, {0.000232847}, {0.000226755}, {0.00022046}, \
{0.000213969}, {0.000207287}, {0.000200421}, {0.000193377}, {0.00018616}, \
{0.000178777}, {0.000171235}, {0.000163541}, {0.000155701}, {0.000147722}, \
{0.000139612}, {0.000131377}, {0.000123025}, {0.000114564}, {0.000106001}, \
{0.0000973433}, {0.0000885989}, {0.0000797756}, {0.0000708813}, \
{0.0000619239}, {0.0000529113}, {0.0000438516}, {0.0000347528}, \
{0.000025623}, {0.0000164705}, {7.30327*10^-6}, {-1.87045*10^-6}, \
{-0.0000110425}, {-0.0000202047}, {-0.000029349}, {-0.0000384671}, \
{-0.0000475509}, {-0.0000565924}, {-0.0000655834}, {-0.0000745161}, \
{-0.0000833824}, {-0.0000921744}, {-0.000100884}, {-0.000109504}, \
{-0.000118027}, {-0.000126445}, {-0.000134749}, {-0.000142934}, \
{-0.000150992}, {-0.000158915}, {-0.000166696}, {-0.000174329}, \
{-0.000181807}} // Flatten;

Use the DataRange option to ListPlot or ListLinePlot

ListLinePlot[amp, DataRange -> {0.001, 0.338}]

enter image description here

time = Table[n*0.001, {n, Length[amp]}];

data = Transpose[{time, amp}];

The interpolation function is

f = Interpolation[data];

Use f like any other function, e.g.,

f[0.1]

(*  0.0000571468  *)

Plot[f[t], {t, 0.001, 0.338}]

enter image description here

$\endgroup$
3
$\begingroup$

There is often a confusion between fit and interpolation.Comments suggest that you tried FindFit as well.

So here is a solution with NonLinearModelFit to complement @BobHanlon's interpolation answer.

data = MapIndexed[{0.001 First@ #2, #1} &, amp, {1}]; (* makes a list of pairs *)

nlm = NonlinearModelFit[data, 
     {a Sin[2 Pi x/per], 0.1 < per < 0.3, 2 10^-4 < a < 3.5 10^-4}, {a, per}, x]

Show[Plot[nlm[x], {x, 0.001, 0.338}, PlotStyle -> Red], 
   ListPlot[data[[Range[1, Length@data, 5]]]]]

I was taking every 5th point of your data so the dots are more visible.

enter image description here

$\endgroup$

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