Matlab样条插值从Y中查找X [英] Matlab Spline Interpolation Find X from Y

查看:370
本文介绍了Matlab样条插值从Y中查找X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当y = 0时,我需要找到x的值.

I need to find the value of x when y = 0.

这是我的代码:

x=[2,3,4,5,6]; 
y=[10,8,4,1,-2]; 
xi=linspace(2,6,100); 
yi=interp1(x,y,xi,'spline'); 
plot(x,y,'o',xi,yi,'-') 
xlabel('x')
 ylabel('y') 
title('Data')

我尝试使用fzero,但找不到正确的语法.

I tried using fzero, but I couldn't figure out the proper syntax.

我没有要使用的函数f(x),只有给定的要点.

I do not have a function f(x) to use, only the points given.

推荐答案

需要注意的几点:

  1. 'spline'是指三次样条曲线.绝对确定这是您想要的插值技术.使用xi=linspace(0,6,100);
  2. 重新运行代码
  3. 可以在插值函数上调用fzero函数:

  1. 'spline' refers to cubic spline. Be absolutely certain that is the interpolation technique that you want. Rerun your code with xi=linspace(0,6,100);
  2. The fzero function can be called on the interpolation function:

fzero(@(xi)interp1(x,y,xi,'spline'),5)

这篇关于Matlab样条插值从Y中查找X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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