500*_*500 4 wolfram-mathematica intersection solution
考虑以下 :
daList = {{541, 0.0593368}, {550, 0.298352}, {560, 0.72619}, {570,0.734982},
{580, 1.46149}, {590, 2.31119}, {600, 3.31509}}
Run Code Online (Sandbox Code Playgroud)
每个子列表代表{x,y}坐标.
我需要找到Y等于1的x值.用眼睛大约575.
ListPlot[daList,
Joined -> True,
Epilog ->{Thick, Line[{{0, 1}, {600, 1}}]}]
Run Code Online (Sandbox Code Playgroud)
+来自PPT的红色部分的帮助来说明问题:

可以插值直到找到1,但我想知道Mathematica中是否存在这个函数.
无论是计算.找到y = 1的X.或者可以是在x轴上报告线交点x坐标的图形.
f = Interpolation[daList];
r = FindRoot[Evaluate[f][x] - 1, {x, 570, 541, 600}]
Show[Plot[{f[x], 1}, {x, 541, 600}], Graphics@Line[{{x, 0}, {x, 1}}] /. r]
Run Code Online (Sandbox Code Playgroud)

编辑
有了传说:
f = Interpolation[daList];
r = FindRoot[Evaluate[f][x] - 1, {x, 570, 541, 600}]
Show[Plot[{f[x], 1}, {x, 541, 600}, PlotRangePadding -> 1, Frame -> True,
Axes -> False,
Epilog -> Inset[Framed[Style[x /. r, Medium, Bold, Red],
Background -> LightYellow],
{x, 0} /. r]],
Graphics[Line[{{x, -1}, {x, 1}}] /. r]]
Run Code Online (Sandbox Code Playgroud)

你可以使用Interpolation和翻转x和y坐标来返回InterpolatingFunction带y参数的东西.假设您想要线性插值,请按以下步骤操作:
f = Interpolation[daList ~Reverse~ 2, InterpolationOrder -> 1];
f[1]
Out[1]=573.648
Run Code Online (Sandbox Code Playgroud)
这是基于线性交叉和线性插值的解决方案.它会找到所有的过境点.
crossing[y_][ln : {{x1_, y1_}, {x2_, y2_}}] :=
Quiet[(x1 y - x2 y - Det@ln)/(y1 - y2)] //
If[Sort[{x1, #, x2}][[2]] == #, #, Sequence @@ {}] &
crossing[1] /@ Partition[daList, 2, 1]
Run Code Online (Sandbox Code Playgroud)
{573.648}
多个交叉点:
points = Table[{x, Sin[x]}, {x, 0, 10, 0.2}];
ListLinePlot[{points, {{0, 0.2}, {10, 0.2}}}]
Run Code Online (Sandbox Code Playgroud)

crossing[0.2] /@ Partition[points, 2, 1]
Run Code Online (Sandbox Code Playgroud)
{0.201395, 2.93926, 6.48559, 9.22311}
| 归档时间: |
|
| 查看次数: |
3613 次 |
| 最近记录: |