MATLAB:插值找到一个线和曲线之间的交点的x值 [英] MATLAB: Interpolating to find the x value of the intersection between a line and a curve

查看:1670
本文介绍了MATLAB:插值找到一个线和曲线之间的交点的x值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是图我现在有

Here is the graph I currently have :

在蓝色虚线重新presented对应于我要找的x值y值。我试图找到行与蓝色曲线(上部)交叉口的x值。自interesections不属于上已经被定义,我们需要插即落到上面的曲线的一个点一个点。

The Dotted Blue line represented the y value that corresponds to the x value I am looking for. I am trying to find the x values of the line's intersections with the blue curve(Upper).Since the interesections do not fall on a point that has already been defined, we need to interpolate a point that falls onto the Upper plot.

下面是我的信息有:

LineValue - 的交点的y值,虚线的数值(y = LineValue)
频率 - 含x的值坐标的数组看到这个情节。对应于LineValue频率的插值是我们正在寻找
上/下 - 包含Y值信息为这个图形阵列

LineValue - The y value of the intersection and the value of the dotted line( y = LineValue) Frequency - an array containing the x value coordinates seen on this plot. The interpolated values of Frequency that corresponds to LineValue are what we are looking for Upper/Lower - arrays containing the y value info for this graph

推荐答案

使用示例解决方案的 FZERO

%# data resembling your curve
x = linspace(-100,100,100);
f = @(x) 1-2.*exp(-0.5*x.^2./20)./(2*pi) + randn(size(x))*0.002;
VALUE = 0.8;

%# solve f(x)=VALUE
z1 = fzero(@(x)f(x)-VALUE, -10);  %# find solution near x=-10
z2 = fzero(@(x)f(x)-VALUE, 10);   %# find solution near x=+10

%# plot
plot(x,f(x),'b.-'), hold on
plot(z1, VALUE, 'go', z2, VALUE, 'go')
line(xlim(), [VALUE VALUE], 'Color',[0.4 0.4 0.4], 'LineStyle',':')
hold off

这篇关于MATLAB:插值找到一个线和曲线之间的交点的x值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆