在Mathematica中,如何使插值与ListLinePlot一样好?

时间:2014-12-02 04:15:40

标签: wolfram-mathematica interpolation

首先,我从中学习 In Mathematica, what interpolation function is ListPlot using? ListPlot用于插值的方法是将每个坐标插值为列表索引的函数。我认为ListLinePlot可以决定采用哪种InterpolationOrder。 如果我更改InterpolationOrder - > 3进入InterpolationOrder - > 1,我的数据的内插更像是ListLinePlot的图。 这是数据和代码:

那么,有什么方法可以插入我的数据并将其绘制成与ListLinePlot一样好的方法吗?或者有没有办法让我的插值更“聪明”,所以它也可以决定InterpolationOrder本身? 这是数据和代码:

mypoint = {{1.3336020610508064`, 
0.05630827677109675`}, {1.5103543939292194`, 
0.05790550283922009`}, {1.6927497417380886`, 
0.07151008153610137`}, {1.840047310044461`, 
0.11741226450605104`}, {1.9209270855795286`, 
0.2726755425789721`}, {1.953407919235778`, 
2.0759615023390294`}, {1.9550995254889463`, 0.7164793699550908`}};
interpcut[r_, x_] := Module[{s}, s = SortBy[r, First];
Piecewise[{{0, x < First[s][[1]]}, {0, 
 x > Last[s][[1]]}, {Interpolation[r, InterpolationOrder -> 3][x],
  True}}]];
Interpolation1[x_] := interpcut[mypoint, x];
ListPlot[mypoint, PlotStyle -> Orange]
ListLinePlot[mypoint, PlotStyle -> Orange]
Plot[Interpolation1[x], {x, 1.3, 2}, PlotRange -> All, 
 PlotStyle -> Orange]

感谢,  Jzm

关于@agentp的问题:

mypoint1 = {{1.3336020610508064`, 
0.05630827677109675`}, {1.5103543939292194`, 
0.05790550283922009`}, {1.6927497417380886`, 
0.07151008153610137`}, {1.840047310044461`, 
0.11741226450605104`}, {1.9209270855795286`, 
0.2726755425789721`}, {1.953407919235778`, 
2.0759615023390294`}, {1.9550995254889463`, 0.7164793699550908`}};
interpcut[r_, x_] := Module[{s},(*sort array by x coord*)s = SortBy[r, First];
Piecewise[{{0, x < First[s][[1]] + 0.002}, {0, 
 x > Last[s][[1]] - 0.002}, {Interpolation[r][x], True}}]];
Group1point = ListPlot[mypoint1, PlotStyle -> Red];
Group1Interpolation[x_] := interpcut[mypoint1, x];
Group1line = Plot[Group1Interpolation[x], {x, 1.3, 2}, PlotRange -> All, PlotStyle -> Red];
Show[{Group1point, Group1line}, Frame -> True, ImageSize -> 500]

0 个答案:

没有答案