声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2004|回复: 6

[编程技巧] 插值问题

[复制链接]
发表于 2007-5-30 21:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
T1        T2        T3        T4        T5        T6        T7        T8        T9        T10
1mm        2mm        3mm        4mm        5mm        6mm        7mm        8mm        9mm        10mm
D1        D2        D3         D4         D5        D6        D7        D8        D9        D10
                2.67        1.52        1.02        0.75        0.57        0.48        0.43        0.41

如上面的数据,若用拉格朗日插值,误差太大.请问有别的什么函数可以差值吗?所要插的值已经超出了X的范围,如果有.请将具体的程序写一下.谢谢啦!!

[ 本帖最后由 eight 于 2007-5-30 21:51 编辑 ]
回复
分享到:

使用道具 举报

发表于 2007-5-30 21:51 | 显示全部楼层
原帖由 120871464 于 2007-5-30 21:33 发表
T1        T2        T3        T4        T5        T6        T7        T8        T9        T10
1mm        2mm        3mm        4mm        5mm        6mm        7mm        8mm        9mm        10mm
D1        D2        D3         D4         D5        D6        D7        D8        D9        D10
                2.67        1.52        1.02        0.75        0.57        0.48        0.43        0.41

如上面的数据,若用拉各朗日插值,误差太大.请问 ...


help interp1
 楼主| 发表于 2007-5-31 09:22 | 显示全部楼层
没有这个啊
我 找过了
搜不到
发表于 2007-5-31 09:25 | 显示全部楼层
有的   INTERP1 1-D interpolation (table lookup)
    YI = INTERP1(X,Y,XI) interpolates to find YI, the values of the
    underlying function Y at the points in the array XI. X must be a
    vector of length N.
    If Y is a vector, then it must also have length N, and YI is the
    same size as XI.  If Y is an array of size [N,D1,D2,...,Dk], then
    the interpolation is performed for each D1-by-D2-by-...-Dk value
    in Y(i,:,:,...,:).
    If XI is a vector of length M, then YI has size [M,D1,D2,...,Dk].
    If XI is an array of size [M1,M2,...,Mj], then YI is of size
    [M1,M2,...,Mj,D1,D2,...,Dk].

    YI = INTERP1(Y,XI) assumes X = 1:N, where N is LENGTH(Y)
    for vector Y or SIZE(Y,1) for array Y.

    Interpolation is the same operation as "table lookup".  Described in
    "table lookup" terms, the "table" is [X,Y] and INTERP1 "looks-up"
    the elements of XI in X, and, based upon their location, returns
    values YI interpolated within the elements of Y.

    YI = INTERP1(X,Y,XI,METHOD) specifies alternate methods.
    The default is linear interpolation. Use an empty matrix [] to specify
    the default. Available methods are:

      'nearest'  - nearest neighbor interpolation
      'linear'   - linear interpolation
      'spline'   - piecewise cubic spline interpolation (SPLINE)
      'pchip'    - shape-preserving piecewise cubic interpolation
      'cubic'    - same as 'pchip'
      'v5cubic'  - the cubic interpolation from MATLAB 5, which does not
                   extrapolate and uses 'spline' if X is not equally
                   spaced.

    YI = INTERP1(X,Y,XI,METHOD,'extrap') uses the specified method for
    extrapolation for any elements of XI outside the interval spanned by X.
    Alternatively, YI = INTERP1(X,Y,XI,METHOD,EXTRAPVAL) replaces
    the values outside of the interval spanned by X with EXTRAPVAL.
    NaN and 0 are often used for EXTRAPVAL.  The default extrapolation
    behavior with four input arguments is 'extrap' for 'spline' and 'pchip'
    and EXTRAPVAL = NaN for the other methods.

    PP = INTERP1(X,Y,METHOD,'pp') will use the specified method to
    generate the ppform (piecewise polynomial form) of Y. The method may be
    any of the above except for 'v5cubic'. PP may then be evaluated via
    PPVAL. PPVAL(PP,XI) is the same as INTERP1(X,Y,XI,METHOD,'extrap').

    For example, generate a coarse sine curve and interpolate over a
    finer abscissa:
        x = 0:10; y = sin(x); xi = 0:.25:10;
        yi = interp1(x,y,xi); plot(x,y,'o',xi,yi)

    For a multi-dimensional example, we construct a table of functional
    values:
        x = [1:10]'; y = [ x.^2, x.^3, x.^4 ];
        xi = [ 1.5, 1.75; 7.5, 7.75]; yi = interp1(x,y,xi);

    creates 2-by-2 matrices of interpolated function values, one matrix for
    each of the 3 functions. yi will be of size 2-by-2-by-3.
 楼主| 发表于 2007-5-31 10:31 | 显示全部楼层
但是,如果 Xi 的范围超出了 X 的范围怎么拟合啊

[ 本帖最后由 eight 于 2007-5-31 11:24 编辑 ]
发表于 2007-5-31 11:20 | 显示全部楼层
原帖由 120871464 于 2007-5-31 10:31 发表
但是,如果Xi的范围超出了X的范围怎么拟和啊


没说明白呀
发表于 2007-5-31 11:25 | 显示全部楼层
原帖由 120871464 于 2007-5-31 10:31 发表
但是,如果 Xi 的范围超出了 X 的范围怎么拟合啊


interp1 函数会自动处理,无需担心,如果想了解具体的延托算法,请看看 interp1 函数的代码
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-26 19:25 , Processed in 0.068702 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表