交集或求解

问题描述 投票:0回答:4

考虑以下事项:

daList = {{541, 0.0593368}, {550, 0.298352}, {560, 0.72619}, {570,0.734982}, 
          {580, 1.46149}, {590, 2.31119}, {600, 3.31509}}

每个子列表代表一个 {x,y} 坐标。

我需要找到 Y 等于 1 时的 x 值。目测大约为 575。

ListPlot[daList, 
        Joined -> True, 
        Epilog ->{Thick, Line[{{0, 1}, {600, 1}}]}]

+红色部分的PPT帮助来说明问题:

enter image description here

可以插值直到找到 1,但我想知道 Mathematica 中是否存在这样的函数。

要么是计算。求 y = 1 时的 X。 或者可能是一个图形,其中线交点 x 坐标在 x 轴上报告。

wolfram-mathematica intersection
4个回答
8
投票
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]

enter image description here

编辑

有图例:

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]]

enter image description here


5
投票

您可以使用

Interpolation
并翻转
x
y
坐标以返回采用
InterpolatingFunction
参数的
y
。假设您想要线性插值,具体方法如下:

f = Interpolation[daList ~Reverse~ 2, InterpolationOrder -> 1];
f[1]

Out[1]=573.648

5
投票

这是一个基于线相交和线性插值的解决方案。 它会找到所有交叉点。

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]
{573.648}

多次穿越:

points = Table[{x, Sin[x]}, {x, 0, 10, 0.2}];

ListLinePlot[{points, {{0, 0.2}, {10, 0.2}}}]

enter image description here

crossing[0.2] /@ Partition[points, 2, 1]
{0.201395, 2.93926, 6.48559, 9.22311}

4
投票

如果您想在不编程的情况下获得快速而粗略的答案,您也可以选择图形并按句点 (.) 键。您将获得一个十字准线光标和一个工具提示,为您提供十字准线的坐标,如下所示:

enter image description here
(十字线不会粘在屏幕转储中)。请注意,这等于巫师先生的结果,与贝利萨留的结果略有不同。这是因为贝利萨留使用的是

Interpolation
,默认设置为
InterpolationOrder
(3)。如果您使用
InterpolationOrder -> 1
,所有答案都同意。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.