![matlab求龙格函数f(x)=1(1+25*x^2)在区间[-1,1]上取n=10的等距节点,分别作多项式插值三次样条插值,第1张 matlab求龙格函数f(x)=1(1+25*x^2)在区间[-1,1]上取n=10的等距节点,分别作多项式插值三次样条插值,第1张](/aiimages/matlab%E6%B1%82%E9%BE%99%E6%A0%BC%E5%87%BD%E6%95%B0f%28x%29%3D1%281%2B25%2Ax%5E2%29%E5%9C%A8%E5%8C%BA%E9%97%B4%5B-1%2C1%5D%E4%B8%8A%E5%8F%96n%3D10%E7%9A%84%E7%AD%89%E8%B7%9D%E8%8A%82%E7%82%B9%EF%BC%8C%E5%88%86%E5%88%AB%E4%BD%9C%E5%A4%9A%E9%A1%B9%E5%BC%8F%E6%8F%92%E5%80%BC%E4%B8%89%E6%AC%A1%E6%A0%B7%E6%9D%A1%E6%8F%92%E5%80%BC.png)
x = linspace(-1,1,10);
x1 = linspace(-1,1,100);
y =1/(1+25x^2);
y1 = interp1(x,y,x1,'cubic');
y2 = interp1(x,y,x1,'spline');
figure();
plot(x,y,'ro');
hold on;
plot(x1,y1,'b',x1,y2,'g');
clc,clear
x=[01 02 015 0 -02 03];
y=[095 084 0876 106 150 072];
p=polyfit(x,y,2)
xi=-02:001:03;
yi=polyval(p,xi);
X=xi;Y=yi;
fun=inline('c(1)X^2+c(2)X+c(3)','c','X');
[c,resnorm,residual,exitflag]=lsqcurvefit(fun,[1,1,1],X,Y);
c,exitflag
matlab中使用插值函数
插值函数(the function of interpolation )
interp1
调用函数的格式(Syntax)
yi = interp1(x,Y,xi)
yi = interp1(Y,xi)
yi = interp1(x,Y,xi,method)
yi = interp1(x,Y,xi,method,'extrap')
yi = interp1(x,Y,xi,method,extrapval)
pp = interp1(x,Y,method,'pp')
调用格式说明(Description)
yi = interp1(x,Y,xi) 返回矢量X和Y决定的根据输入的节点xi时对应的y的值矢量Y是矢量X的一个函数映射
如果Y是一个矩阵,那么插值结果是一个对应的矩阵
[===================================================
yi = interp1(x,Y,xi) returns vector yi containing elements corresponding to the elements of xi and determined by interpolation within vectors x and Y The vector x specifies the points at which the data Y is given If Y is a matrix, then the interpolation is performed for each column of Y and yi is length(xi)-by-size(Y,2)
===================================================]
yi = interp1(x,Y,xi,method)插值中可以使用的方法: 插值方法 说明 nearest 临近的两点插值 linear 线性插值(默认) spline 三次样条插值 pchip 分段三次Hermite插值多项式插值 cubic (作用于pchip相同) v5cubic 用matlab5版本中断三次样条插值 [====================================================
yi = interp1(x,Y,xi,method) interpolates using alternative methods:
methodDescription
nearestNearest neighbor interpolation
linearLinear interpolation (default)
splinesplineCubic spline interpolation
pchipPiecewise cubic Hermite interpolation
cubic(Same as 'pchip')
v5cubicCubic interpolation used in MATLAB 5
======================================================]
简单程序示例
>>x=[00 01 0195 03 0401 05];
>>y=[039849 039695 039142 038138 036812 035206];
>>plot(x,y);
>>T=interp1(x,y,25,'linear') %线性插值
(返回结果T=03862)
>> T=interp1(x,y,25,'nearest') % 两点插值
(返回结果T=03814)
>>T=interp1(x,y,25,'spline') % 三次样条插值
(返回结果T =03867)
>>T=interp1(x,y,25,'cubic') %三次插值
(返回结果T =03867)
以上就是关于matlab求龙格函数f(x)=1/(1+25*x^2)在区间[-1,1]上取n=10的等距节点,分别作多项式插值三次样条插值全部的内容,包括:matlab求龙格函数f(x)=1/(1+25*x^2)在区间[-1,1]上取n=10的等距节点,分别作多项式插值三次样条插值、求高手指点,matlab问题.大概是这个样子的,给一组数据,用二次多项式先插值,再拟合.求程序啊、插值的编程使用等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)