在Mathematica中,ListPlot使用什么插值函数? [英] In Mathematica, what interpolation function is ListPlot using?
问题描述
[下面的屏幕截图]
我正在使用ListPlot在某些数据点之间绘制一条平滑的线.但是我希望能够使用该图的一阶和二阶导数,因此我想我会使用插值法创建一个实际的函数".但是,正如您在图片中看到的那样,它并不平滑.当我执行Plot [Interpolation [...] ...]时,会有一些奇怪的峰值.我想知道ListPlot如何获得它的内插函数,以及如何使用Interpolation []或其他方法获得相同的东西.
谢谢,
罗伯
以下是一些要复制/粘贴的文本:
myPoints = {{0.,3.87},{1.21,4.05},{2.6,4.25},{4.62,4.48},{7.24,4.73},{9.66,4.93},
{12.48,5.14},{14.87,5.33},{17.34,5.55},{19.31,5.78},{20.78,6.01},{22.08,6.34},
{22.82,6.7},{23.2,7.06},{23.41,7.54},{23.52,8.78},{23.59,9.59},{23.62,9.93},
{23.72,10.24},{23.88,10.56},{24.14,10.85},{24.46,11.05},{24.81,11.2},
{25.73,11.44},{27.15,11.63}}
ListPlot[myPoints, Joined -> True, Mesh -> Full]
Plot[Interpolation[myPoints][x], {x, 0, 27.2}]
最后一个有尖峰.
编辑...
Gleno pointed out that my List plot is linear. But what about when both have
InterpolationOrder -> 3?
ListPlot[myPoints, Joined -> True, Mesh -> Full, InterpolationOrder -> 3]
Plot[Interpolation[myPoints, InterpolationOrder -> 3][x], {x, 0, 27.2}]
我相信
ListPlot
用于插值的方法是根据列表索引对每个坐标进行插值.类似于以下内容的内容类似于ListPlot[...,InterpolationOrder->3]
的输出:With[{
xyInterpolation=Interpolation[#,InterpolationOrder->3]&/@Transpose[myPoints]},
ParametricPlot[Through[xyInterpolation[i]],{i,1,Length[myPoints]}]
]
通过这样的插值,您应该能够通过隐式微分(例如dx/dy ==(dx/dt)/(dy/dt).在可能使一些数学家p之以鼻的地方炫耀这种表示法的一种乐趣:)
[Screenshot below]
I was using ListPlot to draw a smooth line through some data points. But I want to be able to work with the 1st and 2nd derivative of the plot, so I thought I'd create an actual "function" using Interpolation. But as you can see in the picture, it's not smooth. There are some strange spikes when I do Plot[Interpolation[...]...]. I'm wondering how ListPlot get's it's interpolated function, and how I can get the same thing, using Interpolation[] or some other method.
thanks,
Rob
Here is some text for copy/paste:
myPoints = {{0.,3.87},{1.21,4.05},{2.6,4.25},{4.62,4.48},{7.24,4.73},{9.66,4.93},
{12.48,5.14},{14.87,5.33},{17.34,5.55},{19.31,5.78},{20.78,6.01},{22.08,6.34},
{22.82,6.7},{23.2,7.06},{23.41,7.54},{23.52,8.78},{23.59,9.59},{23.62,9.93},
{23.72,10.24},{23.88,10.56},{24.14,10.85},{24.46,11.05},{24.81,11.2},
{25.73,11.44},{27.15,11.63}}
ListPlot[myPoints, Joined -> True, Mesh -> Full]
Plot[Interpolation[myPoints][x], {x, 0, 27.2}]
The last one has spikes.
Edit...
Gleno pointed out that my List plot is linear. But what about when both have
InterpolationOrder -> 3?
ListPlot[myPoints, Joined -> True, Mesh -> Full, InterpolationOrder -> 3]
Plot[Interpolation[myPoints, InterpolationOrder -> 3][x], {x, 0, 27.2}]
I believe that the method used by ListPlot
for interpolation is to interpolate each coordinate as a function of the list index. Something like the following looks a lot like the output from ListPlot[...,InterpolationOrder->3]
:
With[{
xyInterpolation=Interpolation[#,InterpolationOrder->3]&/@Transpose[myPoints]},
ParametricPlot[Through[xyInterpolation[i]],{i,1,Length[myPoints]}]
]
From such an interpolation you should be able to grab your derivatives via implicit differentiation, e.g. dx/dy == (dx/dt)/(dy/dt). A delight to flaunt that notation in a place where it might make some mathematicians puke :)
这篇关于在Mathematica中,ListPlot使用什么插值函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!