matlab中matlab最小二乘法拟合拟合样条中有sp=spap2(knots,k,x,y) ,想问一下最后得到的sp.coefs表示什么呢?

您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
MATLAB在化工中的应用_-第4讲插值、拟合与数值微分和积分.ppt 41页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
你可能关注的文档:
··········
··········
插值、拟合与数值微分和积分 天津科大海洋学院 2009-10 本章知识要点 插值简介 Matlab的插值(Interpolation)函数 调用格式: yi=interp1(T,P,Ti, spline) 已知数据向量(x,y),计算并返回在插值向量xi处的函数值 yi=interp1(x,y,xi, ‘method’) yi=interp1(x,y,xi, ‘method’, ‘extrap’) ‘method’用于指定插值算法,其值可以是: ‘nearest’——最近插值 ‘linear’——线性插值(默认值) ‘spline’——分段三次样条插值 ‘pchip’——分段三次Hermite插值 ‘cubic’——与‘pchip’相同
初始数据对于插值的影响 二维插值:interp2 调用格式: zi=interp2(x,y,z,xi,yi,’method’)
‘method’算法属性值可以是; ‘nearest’——最近插值 ‘linear’——线性插值(默认) ‘spline’——三次样条插值(spline) ‘cubic’——立方插值 拟合简介 最小二乘多项式拟合:polyfit 多项式次数对拟合效果的影响 最小二乘法拟合生成样条曲线 拟合得到曲线函数sp以后,可利用fnval()计算任意自变量下的函数值。 数值微分 函数diff 函数gradient 例题 数值积分 自适应Simpson法数值积分:quad() 多重数值积分 样条函数在数值积分与微分中的应用 反应器停留时间分布的混合特性 微分法进行动力学数据分析 梯形法数值积分:trapz() 调用格式: z=trapz(y)
用梯形求积方法计算y的积分近似值。 对于向量y,trapz(y)返回y的积分; 对于矩阵y,trapz(y)返回一行向量,向量中的各元素为矩阵y的对应列
向量的积分值; 调用格式: q=quad(@fun,a,b)
q=quad(@fun,a,b,tol)
q=quad(@fun,a,b,tol,trace,p1,p2,……)
输入参数: fun 被积函数。在定义fun时,被积函数表达
式必须是向量形式,即表达式必须使用点
运算符(.*、./和.^)以支持向量
a,b 即积分限[a,b]
绝对误差限,默认值为1.e-6
直接传递给函数fun的已知参数
输出参数: q
自适应Lobatto法数值积分:quadl() 调用格式同quad 不同积分函数的比较 求积分: 比较cumsum,trapz,quad,quadl的积分精度,该积分的精确解为0. function Cha4demo5 format long d=pi/1000; t=0:d:3* nt=length(t); y=fun(t); sc=cumsum(y)*d; scf=sc(nt) z=trapz(y)*d qd=quad(@fun,0,3*pi,[],1) qd2=quadl(@fun,0,3*pi,[],1) EV=0.; err(1)=abs(scf-EV); err(2)=abs(z-EV)*10; err(3)=abs(qd-EV)*10; err(4)=abs(qd2-EV)*10; bar(err),title('不同积分方法比较'), colormap(summer) text(0.7,7e-4,'矩形法','fontsize',20) text(1.5,5e-4,'梯形法','fontsize',20) text(2.4,3e-4,'Simpson法','fontsize',20) text(3.4,1e-4,'Lobatto法','fontsize',20) %------------------------------------------------------------ function y=fun(t) y=exp(-0.5*t).*sin(t+pi/6) 广义积分 1. 奇点积分
2. 无穷积分 可先选取一个有限的积分区间,如[0,100]计算;在选择一个较大的积分区间,如[0 200]计算,如两次计算结果的差满足一定的精度要求,则可认为此值即为无穷积分的值 fun=inline('1./(sqrt(x).*(exp(x)+1))'); quadl(fun,0,1) quadl(fun,eps,1) 二重积分函数: SS=dblquad(fun,xmin,xmax,ymin,ymax,tol,method) 三重积分函数: SSS=triplequad(fun
正在加载中,请稍后...matlab微分方程系数的确定_百度文库
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
matlab微分方程系数的确定
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
你可能喜欢当前位置:
&50金币求一MATLAB的拟合程序
50金币求一MATLAB的拟合程序
作者 wangj25
这是那个微分方程,有一组数据:& &
dS/dt=-a*S/(b+S+S的平方/c)
注意前面有一个负号。
现在要将曲线拟合出来,求出a、b、 c 的值。并求得相关系数R。
求matlab实现程序。请写下具体程序
[ Last edited by wangj25 on
at 19:42 ]
自己用几个matlalb的非线性拟合函数试试是,应该不难的。
这个是不是可以积出来啊
-(1/2)*a*c*ln(b*c+S*c+S^2)+a*c^2*arctan((c+2*S)/sqrt(4*b*c-c^2))/sqrt(4*b*c-c^2)
积出来是不是这个?
考虑了一阵子发现还真的很是问题啊
matlab似乎没有专门针对微分方程参数拟合的工具,似乎其他软件也不行
可能需要构建特征函数吧?
有一个例子是这样的,不知道与我的相似不
Constant x=214.63;
Parameter q=[0,0.5], k=[0,];
Variable t,s;
ODEFunction s' = -q*S*X/(k+S);
t=[0 2 7 9 19 22 24 26 28 30 32 40];
S=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0];
不要意思,最近比较忙。我给个思路,供您参考。
******************************************
一、先求解S在各个点的微分值dS/t(用最小二乘样条拟合计算dS/t),使用B样条插值函数
程序如下:
T= 你提供的值;
S= 你提供的值;
knots = 3; K = 3;&&%(3次B样条)
sp=spap2(knots,K,T,S);
sp=spap2(newknt(sp),K,T,S);
pp=fnder(sp)
dSdt=fnval(pp,T)
二、再用非线性最小二乘法函数lsqnonlin()拟合参数a、b、 c
lsqnonlin具体用法,参加matlab的帮助文件。
************************************************
引用回帖:: Originally posted by threight at
不要意思,最近比较忙。我给个思路,供您参考。
******************************************
一、先求解S在各个点的微分值dS/t(用最小二乘样条拟合计算dS/t),使用B样条插值函数
程序如下:
T=&&... 我也是这么想的,对于dS/dt变化不剧烈的应该没问题
这样问题就变成了f(a,b,c)的拟合了,这样相对就好办了。
但是如果dS/dt变化剧烈可能就麻烦了,
24小时热帖
下载小木虫APP
与700万科研达人随时交流Mouseover text to see original. Click the button below to return to the English version of the page.
Note: This page has been translated by MathWorks.
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.
Back to English
Select Language
Chinese Simplified
Chinese Traditional
Haitian Creole
Indonesian
Lithuanian
Portuguese
Vietnamese
MathWorks Machine Translation
The automated translation of this page is provided by a general purpose third party translator tool.
MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.
spap2Least-squares spline approximation
Syntaxspap2(knots,k,x,y)
spap2(l,k,x,y)
sp = spap2(...,x,y,w)
spap2({knorl1,...,knorlm},k,{x1,...,xm},y)
spap2({knorl1,...,knorlm},k,{x1,...,xm},y,w)
Descriptionspap2(knots,k,x,y)
the B-form of the spline f of order k with
the given knot sequence knots for which(*)
y(:,j) = f(x(j)), all j
in the weighted mean-square sense, meaning that the sum∑jw(j)|y(:,j)−f(x(j))|2is minimized, with default weights equal to 1.
The data values y(:,j) may be scalars, vectors,
matrices, even ND-arrays, and |z|2 stands
for the sum of the squares of all the entries of z.
Data points with the same site are replaced by their average.If the sites x satisfy the (Schoenberg-Whitney)
conditions           knots(j)<x(j)<knots(j+k)(**)                                j=1,...,length(x)=length(knots)−kthen there is a unique spline (of the given order and knot sequence)
satisfying (*) exactly. No spline is returned unless (**) is satisfied
for some subsequence of x.spap2(l,k,x,y) , with l a positive
integer, returns the B-form of a least-squares spline approximant, but with the knot
sequence chosen for you. The knot sequence is obtained by applying
to an appropriate
subsequence of x. The resulting piecewise-polynomial consists of
l polynomial pieces and has k-2 continuous
derivatives. If you feel that a different distribution of the interior knots might
do a better job, follow this up withsp1 = spap2(newknt(sp),k,x,y));
sp = spap2(...,x,y,w)
lets you specify the weights w in the error measure
(given above). w must be a vector of the same size
as x, with nonnegative entries. All the weights
corresponding to data points with the same site are summed when those
data points are replaced by their average.spap2({knorl1,...,knorlm},k,{x1,...,xm},y)
provides a least-squares spline approximation to gridded data.
Here, each knorli is either a knot sequence or
a positive integer. Further, k must be an m-vector,
and y must be an (r+m)-dimensional
array, with y(:,i1,...,im) the datum to be fitted
at the site [x{1}(i1),...,x{m}(im)],
all i1, ..., im. However, if
the spline is to be scalar-valued, then, in contrast to the univariate
case, y is permitted to be an m-dimensional
array, in which case y(i1,...,im) is the datum
to be fitted at the site [x{1}(i1),...,x{m}(im)],
all i1, ..., im. spap2({knorl1,...,knorlm},k,{x1,...,xm},y,w)
also lets you specify the weights. In this m-variate
case, w must be a cell array with m entries,
with w{i} a nonnegative vector of the same size
as xi, or else w{i} must be
empty, in which case the default weights are used in the ith
variable.Examplessp = spap2(augknt([a,xi,b],4),4,x,y)
is the least-squares approximant to the data x, y,
by cubic splines with two continuous derivatives, basic interval
[a..b], and interior breaks xi,
provided xi has all its entries in (a..b) and
the conditions (**) are satisfied in some fashion. In that case, the
approximant consists of length(xi)+1 polynomial
pieces. If you do not want to worry about the conditions (**) but
merely want to get a cubic spline approximant consisting of l polynomial
pieces, use instead sp = spap2(l,4,x,y);
If the resulting approximation is not satisfactory, try using
a larger l. Else use sp = spap2(newknt(sp),4,x,y);
for a possibly better distribution of the knot sequence. In
fact, if that helps, repeating it may help even more.As another example, spap2(1, 2, x, y); provides
the least-squares straight-line fit to data x,y,
whilew = ones(size(x)); w([1 end]) = 100; spap2(1,2, x,y,w);
forces that fit to come very close to the first data point and
to the last.Algorithms is called
on to provide the almost block-diagonal collocation matrix (Bj,k(xi)),
solves the linear system (*)
in the (weighted) least-squares sense, using a block QR factorization. Gridded data are fitted, in tensor-product fashion, one variable
at a time, taking advantage of the fact that a univariate weighted
least-squares fit depends linearly on the values being fitted.See Also |
Was this topic helpful?
Select Your Location
Choose your location to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a location from the following list:
(Fran?ais)
(Italiano)
Switzerland
Asia Pacific【图文】2-MATLAB在数值分析中的应用_百度文库
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
2-MATLAB在数值分析中的应用
阅读已结束,下载本文到电脑
想免费下载本文?
登录百度文库,专享文档复制特权,积分每天免费拿!
你可能喜欢

我要回帖

更多关于 最小二乘拟合 的文章

 

随机推荐