MATLAB的拟合函数polyfit 的程序代码是什么啊

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 15:49:01
MATLAB的拟合函数polyfit 的程序代码是什么啊
xW[oE+ds!഑B/jqlu;vlgvc'@/ ԗ>&i|3;m U9ߜwΙ\IvZ;\G\|/hS˧._xo??otW^IVΏOsg˟]x|#r u8iDF%F^ N J,3wÛ[&L\!H*H@SBm+tC~ESFza/d"*I: dWy8hLq"Th8k6Lf2x.Ñx&&ӆ}|"HNw=B2qtiv DBQĞ|wgT;ԛ0ilQ?J9J/ z[ k(|f;o;ń}[;-8;תk1KݻSU_%u,PY(8eRX˩L b F0t8&,0]"m(Ԝ -ܥ`̔fJGtڊ ;j!7!0gTFWMB,xF]B+ɒD԰?I uU+ӏMȺ "6DAIgkk﷚E&4U>h}y\^'-lwTyy^hP!1 d,\UR\)of\m2ՂRZWg::(eKQ[y UgƠQ{1!EY8W9Y+J!T F_ۣW@+R"EDbg]jȢ>MLJpFp~ƜlU*T &*v<4])sjis؄^`VaBRкHau(=dy`#?rnnx q*"KɶMPigcF9h(gDqi+xZ4MUϙ4܏SiB&hj#ꂺ9^]T+Zw/o nCSDg,Ϲ G^C7i{e?TX])~hƱsPZc 萣؂Xzc]|W)Pǻ&;<|)ԧœKIfD; p qy{"R tRTg6eV)#< \4@!b Ig8|_6S:z3yL!F#s&!үz2֍z1l)oe>5aV4snr2!N2;uϛj~0ƫ_,A]/hsf:Rk,77tqmALE>oY)H,m?1

MATLAB的拟合函数polyfit 的程序代码是什么啊
MATLAB的拟合函数polyfit 的程序代码是什么啊

MATLAB的拟合函数polyfit 的程序代码是什么啊
polyfit.m 在MATLAB安装目录下 \toolbox\matlab\polyfun
function [p,S,mu] = polyfit(x,y,n)
%POLYFIT Fit polynomial to data.
% P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of
% degree N that fits the data Y best in a least-squares sense.P is a
% row vector of length N+1 containing the polynomial coefficients in
% descending powers,P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1).
%
% [P,S] = POLYFIT(X,Y,N) returns the polynomial coefficients P and a
% structure S for use with POLYVAL to obtain error estimates for
% predictions.S contains fields for the triangular factor (R) from a QR
% decomposition of the Vandermonde matrix of X,the degrees of freedom
% (df),and the norm of the residuals (normr).If the data Y are random,
% an estimate of the covariance matrix of P is (Rinv*Rinv')*normr^2/df,
% where Rinv is the inverse of R.
%
% [P,S,MU] = POLYFIT(X,Y,N) finds the coefficients of a polynomial in
% XHAT = (X-MU(1))/MU(2) where MU(1) = MEAN(X) and MU(2) = STD(X).This
% centering and scaling transformation improves the numerical properties
% of both the polynomial and the fitting algorithm.
%
% Warning messages result if N is >= length(X),if X has repeated,or
% nearly repeated,points,or if X might need centering and scaling.
%
% Class support for inputs X,Y:
% float:double,single
%
% See also POLY,POLYVAL,ROOTS.
% Copyright 1984-2004 The MathWorks,Inc.
% $Revision:5.17.4.5 $ $Date:2004/07/05 17:01:37 $
% The regression problem is formulated in matrix format as:
%
% y = V*p or
%
% 3 2
% y = [x x x 1] [p3
% p2
% p1
% p0]
%
% where the vector p contains the coefficients to be found.For a
% 7th order polynomial,matrix V would be:
%
% V = [x.^7 x.^6 x.^5 x.^4 x.^3 x.^2 x ones(size(x))];
if isequal(size(x),size(y))
error('MATLAB:polyfit:XYSizeMismatch',...
'X and Y vectors must be the same size.')
end
x = x(:);
y = y(:);
if nargout > 2
mu = [mean(x); std(x)];
x = (x - mu(1))/mu(2);
end
% Construct Vandermonde matrix.
V(:,n+1) = ones(length(x),1,class(x));
for j = n:-1:1
V(:,j) = x.*V(:,j+1);
end
% Solve least squares problem.
[Q,R] = qr(V,0);
ws = warning('off','all');
p = R\(Q'*y); % Same as p = V\y;
warning(ws);
if size(R,2) > size(R,1)
warning('MATLAB:polyfit:PolyNotUnique',...
'Polynomial is not unique; degree >= number of data points.')
elseif condest(R) > 1.0e10
if nargout > 2
warning('MATLAB:polyfit:RepeatedPoints',...
'Polynomial is badly conditioned.Remove repeated data points.')
else
warning('MATLAB:polyfit:RepeatedPointsOrRescale',...
['Polynomial is badly conditioned.Remove repeated data points\n' ...
' or try centering and scaling as described in HELP POLYFIT.'])
end
end
r = y - V*p;
p = p.'; % Polynomial coefficients are row vectors by convention.
% S is a structure containing three elements:the triangular factor from a
% QR decomposition of the Vandermonde matrix,the degrees of freedom and
% the norm of the residuals.
S.R = R;
S.df = length(y) - (n+1);
S.normr = norm(r);

MATLAB的拟合函数polyfit 的程序代码是什么啊 怎样利用matlab的polyfit函数拟合一个多项式 matlab polyfit 函数可以计算拟合误差吗?怎么算的呢? matlab的函数拟合 matlab polyfit拟合出来的函数怎样分析其精确程度?用误差分析怎么算?结果具体怎样分析? 运行matlab中的polyfit多项式拟合函数,其中S的结果为R:[3x3 double] df:109 normr:27.2741 matlab中polyfit的 二次多项式拟合 是最小二乘拟合吗?求解释 matlab 最小二乘法拟合曲线代码有没有不用polyfit函数的?拟合Q与H、N、还有效率之间的关系,不用polyfit,谁能帮我写一段正确的代码啊...刚接触Matlab,实在是不会做了 在matlab中由函数polyfit拟合的曲线如何绘制出某一确定点的切线(在同一个图中)?三次拟合曲线 在用matlab进行数值拟合时,在知道x,y两组数据后,怎样实现数据的拟合 除了用polyfit 函数外那自己编写程序怎样来实现拟合 matlab 关于拟合的问题我有一组x和y 要验证他们的乘积为常数 使用拟合对么 拟合的过程到底是一个怎样的过程啊 我知道polyfit和polyval函数 拟合的过程是改变polyfit中的参数n 来肉眼看哪种最图 matlab中的polyfit用做拟合,如何确定多项式的阶数n呢?即polyfit(x,y,n)中的n. matlab中用polyfit求出拟合函数的系数后 怎么显示出完整的拟合函数[p,s]=polyfit(t,g,4)p =0.0000 0.0082 -0.1314 0.0889 -0.0137我想在程序的最后完整的显示出p=0.0082*x^3-0.1314*x^2+0.0889*x-0,0137啊?而不是系数矩 用matlab进行曲线拟合的问题!已知几个点的x,y坐标,现在想用matlab进行多项式曲线拟合.分别用了cftool工具和polyfit函数进行拟合,发现了一个问题,是不是用matlab进行拟合多项式拟合时,最高阶次只 matlab中线性拟合的函数是什么? MATLAB拟合类似反比例函数的程序. matlab的函数的拟合和求导t=0:0.02:0.18y=[415.7 415.68 415.65 415.55 415.38 415.2 415.07 414.96 414.85 414.5 ]n=5 p=polyfit(t,y,n) 如何拟合出一个平滑的曲线然后拟合出一个5次多项式并对多项式进行求导拟合一 如何寻找最好的拟合曲线?以及matlab中Polyfit的用法?主要有两个问题:1 对于一组离散点,如何寻找最好的拟合函数(曲线)?比如这组离散点,究竟是该选择多项式拟合合理,还是选用指数函数拟合更